Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-03-06 12:58:54 +0000
committerAlexander Kurtakov2018-03-06 12:58:54 +0000
commit77c4374df19895b247e6853c9588644f34c16dca (patch)
tree1552faf8c0b70a2620adce12b04a2be320da59e3
parent2ece39ab0f3b9408e24d7f0a3694a848bcb33184 (diff)
downloadorg.eclipse.dltk.core-77c4374df19895b247e6853c9588644f34c16dca.tar.gz
org.eclipse.dltk.core-77c4374df19895b247e6853c9588644f34c16dca.tar.xz
org.eclipse.dltk.core-77c4374df19895b247e6853c9588644f34c16dca.zip
Cleanup dltk.ui bundle.
Mostly unneeded else clauses and autoformating but other small fixes also while looking at the code. Change-Id: I71bdb778985270192a2007c1b01cbc460295c1c5 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF1
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java86
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java187
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java7
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java27
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java35
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java74
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java11
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java62
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java57
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java66
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java43
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java14
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java79
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java24
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java171
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java139
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java105
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java42
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java200
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java73
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java30
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java11
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java23
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java392
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java109
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java96
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java560
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java13
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java36
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java41
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java53
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java21
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java53
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java56
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java42
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java271
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java125
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java10
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java147
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java19
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java6
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java254
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java96
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java62
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java25
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java14
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java18
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java17
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java33
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java83
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java750
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java25
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java6
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java31
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java75
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java26
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java231
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java18
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java38
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java36
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java17
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java92
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java179
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java26
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java61
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java87
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java29
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java14
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java14
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java74
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java51
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java32
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java20
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java11
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java63
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java7
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java48
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java424
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java67
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java40
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java64
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java7
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java128
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java150
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java81
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java141
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java58
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java110
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/ScriptWorkingSetPage.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/WorkingSetFilter.java102
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ColorPreferenceConverter.java21
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ModelElementSorter.java53
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ScriptElementImageProvider.java11
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/FindAction.java172
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/IndentAction.java83
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/SelectionDispatchAction.java177
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackage.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackagesProvider.java128
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesView.java127
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewFlatContentProvider.java22
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewHierarchicalContentProvider.java60
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewLabelProvider.java23
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ProjectsView.java14
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java65
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java30
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/MultiSelectionListViewer.java3
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/dialogs/FilteredTypesSelectionDialog.java95
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/documentation/ScriptDocumentationAccess.java22
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/highlighting/ASTSemanticHighlighter.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/saveparticipant/SaveParticipantRegistry.java12
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/environment/EnvironmentContainer.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/AbstractDocumentationView.java36
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/ModelElementArray.java11
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/TextSelectionConverter.java29
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java36
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractScriptEditorColoringConfigurationBlock.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/CodeTemplateBlock.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/EditTemplateDialog.java29
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferenceChangeRebuildPrompt.java9
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java19
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/refactoring/RenameSupport.java75
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/templates/ScriptTemplateCompletionProcessor.java10
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/HTMLUtils.java15
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCommentScanner.java10
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionAssistant.java29
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionContext.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptDefaultIndentLineAutoEditStrategy.java51
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptOutlineInformationControl.java17
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/AbstractScriptCompletionProposal.java85
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalComparator.java13
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalLabelProviderRegistry.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/LazyScriptCompletionProposal.java76
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposal.java86
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposalComputer.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptContentAssistInvocationContext.java48
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/AbstractASTFoldingStructureProvider.java58
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/DelegatingFoldingStructureProvider.java44
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/FoldingProviderManager.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/rules/FloatNumberRule.java31
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/spelling/SpellCheckDelegate.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/templates/ProjectTemplateStore.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ExceptionHandler.java52
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ScriptProjectNaturePropertyTester.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/ResourceToItemsMapper.java99
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/StatusBarUpdater.java40
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/BuildpathsBlock.java28
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewContainerWizardPage.java122
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleInPackagePage.java31
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleWizard.java7
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectCreator.java24
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectWizardFirstPage.java44
-rw-r--r--core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/WorkingSetDetector.java21
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/DelegateUIHelper.java8
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DeleteWizard.java162
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DestinationContentProvider.java67
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/PasteAction.java27
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameInputWizardPage.java21
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameSourceModuleWizard.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgMoveWizard.java5
-rw-r--r--core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgQueries.java382
177 files changed, 5749 insertions, 5226 deletions
diff --git a/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF b/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
index 7c0cb4e07..2d2f00ed5 100644
--- a/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
+++ b/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
@@ -108,3 +108,4 @@ Export-Package: org.eclipse.dltk.corext,
org.eclipse.dltk.ui.wizards
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: org.eclipse.dltk.ui
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
index e396ce7ba..acfffd780 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.corext.refactoring;
@@ -16,48 +15,49 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.ScriptModelUtil;
-import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.ScriptModelUtil;
import org.eclipse.dltk.internal.corext.refactoring.changes.RenameResourceChange;
import org.eclipse.dltk.internal.corext.refactoring.util.ResourceUtil;
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.dltk.internal.corext.util.Resources;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-
/**
* This class defines a set of reusable static checks methods.
*/
public class Checks {
-
+
/*
* no instances
*/
- private Checks(){
+ private Checks() {
}
-
+
/* Constants returned by checkExpressionIsRValue */
- public static final int IS_RVALUE= 0;
- public static final int NOT_RVALUE_MISC= 1;
- public static final int NOT_RVALUE_VOID= 2;
-
- public static boolean isAvailable(IModelElement modelElement) throws ModelException {
+ public static final int IS_RVALUE = 0;
+ public static final int NOT_RVALUE_MISC = 1;
+ public static final int NOT_RVALUE_VOID = 2;
+
+ public static boolean isAvailable(IModelElement modelElement)
+ throws ModelException {
if (modelElement == null)
return false;
- if (! modelElement.exists())
+ if (!modelElement.exists())
return false;
if (modelElement.isReadOnly())
return false;
// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=48422
- // the Script project is now cheating regarding its children so we shouldn't
+ // the Script project is now cheating regarding its children so we
+ // shouldn't
// call isStructureKnown if the project isn't open.
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=52474
- if (!(modelElement instanceof IScriptProject) && !modelElement.isStructureKnown())
+ if (!(modelElement instanceof IScriptProject)
+ && !modelElement.isStructureKnown())
return false;
if (DLTKCore.DEBUG) {
System.err.println("Add binary modules support."); //$NON-NLS-1$
@@ -66,42 +66,54 @@ public class Checks {
// return false;
return true;
}
+
public static boolean isBuildpathDelete(IProjectFragment pkgRoot) {
- IResource res= pkgRoot.getResource();
+ IResource res = pkgRoot.getResource();
if (res == null)
return true;
- IProject definingProject= res.getProject();
- if (res.getParent() != null && pkgRoot.isArchive() && !res.getParent().equals(definingProject))
+ IProject definingProject = res.getProject();
+ if (res.getParent() != null && pkgRoot.isArchive()
+ && !res.getParent().equals(definingProject))
return true;
-
- IProject occurringProject= pkgRoot.getScriptProject().getProject();
+
+ IProject occurringProject = pkgRoot.getScriptProject().getProject();
return !definingProject.equals(occurringProject);
}
- public static RefactoringStatus checkSourceModuleNewName(ISourceModule cu, String newName) {
- String newCUName= ScriptModelUtil.getRenamedCUName(cu, newName);
- if (resourceExists(RenameResourceChange.renamedResourcePath(ResourceUtil.getResource(cu).getFullPath(), newCUName)))
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, newName));
- else
- return new RefactoringStatus();
+
+ public static RefactoringStatus checkSourceModuleNewName(ISourceModule cu,
+ String newName) {
+ String newCUName = ScriptModelUtil.getRenamedCUName(cu, newName);
+ if (resourceExists(RenameResourceChange.renamedResourcePath(
+ ResourceUtil.getResource(cu).getFullPath(), newCUName))) {
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.Checks_cu_name_used, newName));
+ }
+ return new RefactoringStatus();
}
- public static boolean resourceExists(IPath resourcePath){
- return ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath) != null;
+
+ public static boolean resourceExists(IPath resourcePath) {
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(resourcePath) != null;
}
- public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
- RefactoringStatus result= new RefactoringStatus();
- IStatus status= Resources.checkInSync(filesToModify);
+
+ public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify,
+ Object context) {
+ RefactoringStatus result = new RefactoringStatus();
+ IStatus status = Resources.checkInSync(filesToModify);
if (!status.isOK())
result.merge(RefactoringStatus.create(status));
- status= Resources.makeCommittable(filesToModify, context);
+ status = Resources.makeCommittable(filesToModify, context);
if (!status.isOK()) {
result.merge(RefactoringStatus.create(status));
if (!result.hasFatalError()) {
- result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
- }
+ result.addFatalError(
+ RefactoringCoreMessages.Checks_validateEdit);
+ }
}
return result;
}
- public static boolean isAlreadyNamed(IModelElement element, String name){
+
+ public static boolean isAlreadyNamed(IModelElement element, String name) {
return name.equals(element.getElementName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java
index 2988c2e93..c91607f8f 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.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
@@ -82,10 +82,10 @@ public final class RefactoringAvailabilityTester {
return isRenameAvailable((IType) element);
case IModelElement.METHOD:
final IMethod method = (IMethod) element;
- if (method.isConstructor())
+ if (method.isConstructor()) {
return isRenameAvailable(method.getDeclaringType());
- else
- return isRenameAvailable(method);
+ }
+ return isRenameAvailable(method);
case IModelElement.FIELD:
final IField field = (IField) element;
return isRenameFieldAvailable(field);
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java
index 3bbd05706..14081d2bf 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.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
@@ -29,7 +29,6 @@ import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
/**
* DLTK specific change object.
*/
@@ -37,7 +36,7 @@ public abstract class DLTKChange extends Change {
private long fModificationStamp;
private boolean fReadOnly;
-
+
private static class ValidationState {
private IResource fResource;
private int fKind;
@@ -45,119 +44,141 @@ public abstract class DLTKChange extends Change {
private boolean fReadOnly;
private long fModificationStamp;
private ITextFileBuffer fTextFileBuffer;
- public static final int RESOURCE= 1;
- public static final int DOCUMENT= 2;
+ public static final int RESOURCE = 1;
+ public static final int DOCUMENT = 2;
+
public ValidationState(IResource resource) {
- fResource= resource;
+ fResource = resource;
if (resource instanceof IFile) {
- initializeFile((IFile)resource);
+ initializeFile((IFile) resource);
} else {
initializeResource(resource);
}
}
- public void checkDirty(RefactoringStatus status, long stampToMatch, IProgressMonitor pm) throws CoreException {
+
+ public void checkDirty(RefactoringStatus status, long stampToMatch,
+ IProgressMonitor pm) throws CoreException {
if (fDirty) {
- if (fKind == DOCUMENT && fTextFileBuffer != null && stampToMatch == fModificationStamp) {
+ if (fKind == DOCUMENT && fTextFileBuffer != null
+ && stampToMatch == fModificationStamp) {
fTextFileBuffer.commit(pm, false);
} else {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_unsaved, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_unsaved,
+ fResource.getFullPath().toString()));
}
}
}
+
public void checkDirty(RefactoringStatus status) {
if (fDirty) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_unsaved, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_unsaved,
+ fResource.getFullPath().toString()));
}
}
+
public void checkReadOnly(RefactoringStatus status) {
if (fReadOnly) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_read_only, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_read_only,
+ fResource.getFullPath().toString()));
}
}
- public void checkSameReadOnly(RefactoringStatus status, boolean valueToMatch) {
+
+ public void checkSameReadOnly(RefactoringStatus status,
+ boolean valueToMatch) {
if (fReadOnly != valueToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_same_read_only,
- fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_same_read_only,
+ fResource.getFullPath().toString()));
}
}
- public void checkModificationStamp(RefactoringStatus status, long stampToMatch) {
+
+ public void checkModificationStamp(RefactoringStatus status,
+ long stampToMatch) {
if (fKind == DOCUMENT) {
- if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && fModificationStamp != stampToMatch) {
+ if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
+ && fModificationStamp != stampToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_has_modifications, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_has_modifications,
+ fResource.getFullPath().toString()));
}
} else {
- if (stampToMatch != IResource.NULL_STAMP && fModificationStamp != stampToMatch) {
+ if (stampToMatch != IResource.NULL_STAMP
+ && fModificationStamp != stampToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_has_modifications, fResource.getFullPath().toString()));
-
+ RefactoringCoreMessages.Change_has_modifications,
+ fResource.getFullPath().toString()));
+
}
}
}
+
private void initializeFile(IFile file) {
- fTextFileBuffer= getBuffer(file);
+ fTextFileBuffer = getBuffer(file);
if (fTextFileBuffer == null) {
initializeResource(file);
} else {
- IDocument document= fTextFileBuffer.getDocument();
- fDirty= fTextFileBuffer.isDirty();
- fReadOnly= Resources.isReadOnly(file);
+ IDocument document = fTextFileBuffer.getDocument();
+ fDirty = fTextFileBuffer.isDirty();
+ fReadOnly = Resources.isReadOnly(file);
if (document instanceof IDocumentExtension4) {
- fKind= DOCUMENT;
- fModificationStamp= ((IDocumentExtension4)document).getModificationStamp();
+ fKind = DOCUMENT;
+ fModificationStamp = ((IDocumentExtension4) document)
+ .getModificationStamp();
} else {
- fKind= RESOURCE;
- fModificationStamp= file.getModificationStamp();
+ fKind = RESOURCE;
+ fModificationStamp = file.getModificationStamp();
}
}
-
+
}
+
private void initializeResource(IResource resource) {
- fKind= RESOURCE;
- fDirty= false;
- fReadOnly= Resources.isReadOnly(resource);
- fModificationStamp= resource.getModificationStamp();
+ fKind = RESOURCE;
+ fDirty = false;
+ fReadOnly = Resources.isReadOnly(resource);
+ fModificationStamp = resource.getModificationStamp();
}
}
- protected static final int NONE= 0;
- protected static final int READ_ONLY= 1 << 0;
- protected static final int DIRTY= 1 << 1;
- private static final int SAVE= 1 << 2;
- protected static final int SAVE_IF_DIRTY= SAVE | DIRTY;
-
+ protected static final int NONE = 0;
+ protected static final int READ_ONLY = 1 << 0;
+ protected static final int DIRTY = 1 << 1;
+ private static final int SAVE = 1 << 2;
+ protected static final int SAVE_IF_DIRTY = SAVE | DIRTY;
+
protected DLTKChange() {
- fModificationStamp= IResource.NULL_STAMP;
- fReadOnly= false;
+ fModificationStamp = IResource.NULL_STAMP;
+ fReadOnly = false;
}
-
+
@Override
public void initializeValidationData(IProgressMonitor pm) {
- IResource resource= getResource(getModifiedElement());
+ IResource resource = getResource(getModifiedElement());
if (resource != null) {
- fModificationStamp= getModificationStamp(resource);
- fReadOnly= Resources.isReadOnly(resource);
+ fModificationStamp = getModificationStamp(resource);
+ fReadOnly = Resources.isReadOnly(resource);
}
}
- // protected final RefactoringStatus isValid(IProgressMonitor pm, boolean checkReadOnly, boolean checkDirty) throws CoreException {
- protected final RefactoringStatus isValid(IProgressMonitor pm, int flags) throws CoreException {
+ // protected final RefactoringStatus isValid(IProgressMonitor pm, boolean
+ // checkReadOnly, boolean checkDirty) throws CoreException {
+ protected final RefactoringStatus isValid(IProgressMonitor pm, int flags)
+ throws CoreException {
pm.beginTask("", 2); //$NON-NLS-1$
try {
- RefactoringStatus result= new RefactoringStatus();
- Object modifiedElement= getModifiedElement();
+ RefactoringStatus result = new RefactoringStatus();
+ Object modifiedElement = getModifiedElement();
checkExistence(result, modifiedElement);
if (result.hasFatalError())
return result;
if (flags == NONE)
return result;
- IResource resource= getResource(modifiedElement);
+ IResource resource = getResource(modifiedElement);
if (resource != null) {
- ValidationState state= new ValidationState(resource);
+ ValidationState state = new ValidationState(resource);
state.checkModificationStamp(result, fModificationStamp);
if (result.hasFatalError())
return result;
@@ -171,7 +192,8 @@ public abstract class DLTKChange extends Change {
}
if ((flags & DIRTY) != 0) {
if ((flags & SAVE) != 0) {
- state.checkDirty(result, fModificationStamp, new SubProgressMonitor(pm, 1));
+ state.checkDirty(result, fModificationStamp,
+ new SubProgressMonitor(pm, 1));
} else {
state.checkDirty(result);
}
@@ -187,17 +209,19 @@ public abstract class DLTKChange extends Change {
return isValid(new NullProgressMonitor(), flags);
}
- protected static void checkIfModifiable(RefactoringStatus status, Object element, int flags) {
+ protected static void checkIfModifiable(RefactoringStatus status,
+ Object element, int flags) {
checkIfModifiable(status, getResource(element), flags);
}
- protected static void checkIfModifiable(RefactoringStatus result, IResource resource, int flags) {
+ protected static void checkIfModifiable(RefactoringStatus result,
+ IResource resource, int flags) {
checkExistence(result, resource);
if (result.hasFatalError())
return;
if (flags == NONE)
return;
- ValidationState state= new ValidationState(resource);
+ ValidationState state = new ValidationState(resource);
if ((flags & READ_ONLY) != 0) {
state.checkReadOnly(result);
if (result.hasFatalError())
@@ -208,28 +232,34 @@ public abstract class DLTKChange extends Change {
}
}
- protected static void checkExistence(RefactoringStatus status, Object element) {
+ protected static void checkExistence(RefactoringStatus status,
+ Object element) {
if (element == null) {
- status.addFatalError(RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
-
- } else if (element instanceof IResource && !((IResource)element).exists()) {
+ status.addFatalError(
+ RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
+
+ } else if (element instanceof IResource
+ && !((IResource) element).exists()) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_does_not_exist, ((IResource)element).getFullPath().toString()));
- } else if (element instanceof IModelElement && !((IModelElement)element).exists()) {
+ RefactoringCoreMessages.Change_does_not_exist,
+ ((IResource) element).getFullPath().toString()));
+ } else if (element instanceof IModelElement
+ && !((IModelElement) element).exists()) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_does_not_exist, ((IModelElement)element).getElementName()));
+ RefactoringCoreMessages.Change_does_not_exist,
+ ((IModelElement) element).getElementName()));
}
}
private static IResource getResource(Object element) {
if (element instanceof IResource) {
- return (IResource)element;
+ return (IResource) element;
}
if (element instanceof ISourceModule) {
- return ((ISourceModule)element).getPrimary().getResource();
+ return ((ISourceModule) element).getPrimary().getResource();
}
if (element instanceof IModelElement) {
- return ((IModelElement)element).getResource();
+ return ((IModelElement) element).getResource();
}
if (element instanceof IAdaptable) {
return ((IAdaptable) element).getAdapter(IResource.class);
@@ -241,26 +271,25 @@ public abstract class DLTKChange extends Change {
public String toString() {
return getName();
}
-
+
public long getModificationStamp(IResource resource) {
if (!(resource instanceof IFile))
return resource.getModificationStamp();
- IFile file= (IFile)resource;
- ITextFileBuffer buffer= getBuffer(file);
+ IFile file = (IFile) resource;
+ ITextFileBuffer buffer = getBuffer(file);
if (buffer == null) {
return file.getModificationStamp();
- } else {
- IDocument document= buffer.getDocument();
- if (document instanceof IDocumentExtension4) {
- return ((IDocumentExtension4)document).getModificationStamp();
- } else {
- return file.getModificationStamp();
- }
}
+ IDocument document = buffer.getDocument();
+ if (document instanceof IDocumentExtension4) {
+ return ((IDocumentExtension4) document).getModificationStamp();
+ }
+ return file.getModificationStamp();
}
-
+
private static ITextFileBuffer getBuffer(IFile file) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- return manager.getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE);
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
+ return manager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java
index 15cee8eb0..c7b111b98 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.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
@@ -51,7 +51,7 @@ public class AddToBuildpathChange extends DLTKChange {
*
* @param project
* @param newProjectEntry
- * (must be absolute <code>IPath</code>)
+ * (must be absolute <code>IPath</code>)
*/
public AddToBuildpathChange(IScriptProject project, IPath newProjectEntry) {
this(project, DLTKCore.newProjectEntry(newProjectEntry));
@@ -77,9 +77,8 @@ public class AddToBuildpathChange extends DLTKChange {
IPath buildpathEntryPath = fEntryToAdd.getPath();
return new DeleteFromBuildpathChange(buildpathEntryPath,
getScriptProject());
- } else {
- return new NullChange();
}
+ return new NullChange();
} finally {
pm.done();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java
index 349ae967d..1e2f88084 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.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
@@ -7,6 +7,7 @@
*
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -19,25 +20,25 @@ import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteFileChange extends AbstractDeleteChange {
private final IPath fPath;
private final boolean fIsExecuteChange;
-
+
public DeleteFileChange(IFile file, boolean executeChange) {
- Assert.isNotNull(file, "file"); //$NON-NLS-1$
- fPath= Utils.getResourcePath(file);
- fIsExecuteChange= executeChange;
+ Assert.isNotNull(file, "file"); //$NON-NLS-1$
+ fPath = Utils.getResourcePath(file);
+ fIsExecuteChange = executeChange;
}
-
- private IFile getFile(){
+
+ private IFile getFile() {
return Utils.getFile(fPath);
}
-
+
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.DeleteFileChange_1, fPath.lastSegment());
+ return Messages.format(RefactoringCoreMessages.DeleteFileChange_1,
+ fPath.lastSegment());
}
@Override
@@ -46,9 +47,8 @@ public class DeleteFileChange extends AbstractDeleteChange {
// no need for checking since we already prompt the
// user if the file is dirty or read only
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
@@ -58,7 +58,7 @@ public class DeleteFileChange extends AbstractDeleteChange {
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- IFile file= getFile();
+ IFile file = getFile();
Assert.isNotNull(file);
Assert.isTrue(file.exists());
pm.beginTask("", 2); //$NON-NLS-1$
@@ -74,4 +74,3 @@ public class DeleteFileChange extends AbstractDeleteChange {
return new UndoDeleteResourceChange(resourceDescription);
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java
index 2274ccf58..fb88cdad6 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.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
@@ -25,34 +25,35 @@ import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteFolderChange extends AbstractDeleteChange {
-
+
private final IPath fPath;
private final boolean fIsExecuteChange;
-
+
public DeleteFolderChange(IFolder folder, boolean isExecuteChange) {
this(getFolderPath(folder), isExecuteChange);
}
-
+
public DeleteFolderChange(IPath path, boolean isExecuteChange) {
- fPath= path;
- fIsExecuteChange= isExecuteChange;
+ fPath = path;
+ fIsExecuteChange = isExecuteChange;
}
-
- public static IPath getFolderPath(IFolder folder){
- return folder.getFullPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
+
+ public static IPath getFolderPath(IFolder folder) {
+ return folder.getFullPath().removeFirstSegments(ResourcesPlugin
+ .getWorkspace().getRoot().getFullPath().segmentCount());
}
-
- public static IFolder getFolder(IPath path){
+
+ public static IFolder getFolder(IPath path) {
return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.DeleteFolderChange_0, fPath.lastSegment());
+ return Messages.format(RefactoringCoreMessages.DeleteFolderChange_0,
+ fPath.lastSegment());
}
-
+
@Override
public Object getModifiedElement() {
return getFolder(fPath);
@@ -66,14 +67,13 @@ public class DeleteFolderChange extends AbstractDeleteChange {
// or read only files in the folder. The change is
// currently not used as a undo/redo change
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- IFolder folder= getFolder(fPath);
+ IFolder folder = getFolder(fPath);
Assert.isTrue(folder.exists());
pm.beginTask("", 2); //$NON-NLS-1$
folder.accept((IResourceVisitor) resource -> {
@@ -95,4 +95,3 @@ public class DeleteFolderChange extends AbstractDeleteChange {
return new UndoDeleteResourceChange(resourceDescription);
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java
index b5dfa807d..084526bd3 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.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
@@ -47,26 +47,27 @@ import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteProjectFragmentChange extends AbstractDeleteChange {
private final String fHandle;
private final boolean fIsExecuteChange;
private final IProjectFragmentManipulationQuery fUpdateClasspathQuery;
- public DeleteProjectFragmentChange(IProjectFragment root, boolean isExecuteChange,
+ public DeleteProjectFragmentChange(IProjectFragment root,
+ boolean isExecuteChange,
IProjectFragmentManipulationQuery updateClasspathQuery) {
Assert.isNotNull(root);
- Assert.isTrue(! root.isExternal());
- fHandle= root.getHandleIdentifier();
- fIsExecuteChange= isExecuteChange;
- fUpdateClasspathQuery= updateClasspathQuery;
+ Assert.isTrue(!root.isExternal());
+ fHandle = root.getHandleIdentifier();
+ fIsExecuteChange = isExecuteChange;
+ fUpdateClasspathQuery = updateClasspathQuery;
}
@Override
public String getName() {
- String[] keys= {getRoot().getElementName()};
- return Messages.format(RefactoringCoreMessages.DeleteProjectFragmentChange_delete, keys);
+ return Messages.format(
+ RefactoringCoreMessages.DeleteProjectFragmentChange_delete,
+ getRoot().getElementName());
}
@Override
@@ -74,8 +75,8 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
return getRoot();
}
- private IProjectFragment getRoot(){
- return (IProjectFragment)DLTKCore.create(fHandle);
+ private IProjectFragment getRoot() {
+ return (IProjectFragment) DLTKCore.create(fHandle);
}
@Override
@@ -86,17 +87,17 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
// read only resource. The change is currently not used
// as
return super.isValid(pm, DIRTY);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- if (! confirmDeleteIfReferenced())
+ if (!confirmDeleteIfReferenced())
return new NullChange();
- int resourceUpdateFlags= IResource.KEEP_HISTORY;
- int jCoreUpdateFlags= IProjectFragment.ORIGINATING_PROJECT_BUILDPATH | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH;
+ int resourceUpdateFlags = IResource.KEEP_HISTORY;
+ int jCoreUpdateFlags = IProjectFragment.ORIGINATING_PROJECT_BUILDPATH
+ | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH;
pm.beginTask("", 2); //$NON-NLS-1$
IProjectFragment root = getRoot();
@@ -107,11 +108,11 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
.fromResource(rootResource);
IScriptProject[] referencingProjects = ModelElementUtil
.getReferencingProjects(root);
- HashMap/* <IFile, String> */classpathFilesContents = new HashMap();
+ HashMap<IFile, String> classpathFilesContents = new HashMap<>();
for (int i = 0; i < referencingProjects.length; i++) {
IScriptProject javaProject = referencingProjects[i];
- IFile classpathFile = javaProject.getProject().getFile(
- ScriptProject.BUILDPATH_FILENAME);
+ IFile classpathFile = javaProject.getProject()
+ .getFile(ScriptProject.BUILDPATH_FILENAME);
if (classpathFile.exists()) {
classpathFilesContents.put(classpathFile,
getFileContents(classpathFile));
@@ -123,20 +124,18 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
rootDescription.recordStateFromHistory(rootResource,
new SubProgressMonitor(pm, 1));
- for (Iterator iterator = classpathFilesContents.entrySet().iterator(); iterator
- .hasNext();) {
- Entry entry = (Entry) iterator.next();
- IFile file = (IFile) entry.getKey();
- String contents = (String) entry.getValue();
+ for (Iterator<Entry<IFile, String>> iterator = classpathFilesContents
+ .entrySet().iterator(); iterator.hasNext();) {
+ Entry<IFile, String> entry = iterator.next();
+ IFile file = entry.getKey();
+ String contents = entry.getValue();
// Restore time stamps? This should probably be some sort of
// UndoTextFileChange.
- TextFileChange classpathUndo = new TextFileChange(
- Messages
- .format(
- RefactoringCoreMessages.DeleteProjectFragmentChange_restore_file,
- file.getFullPath().toOSString()), file);
- classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file),
- contents));
+ TextFileChange classpathUndo = new TextFileChange(Messages.format(
+ RefactoringCoreMessages.DeleteProjectFragmentChange_restore_file,
+ file.getFullPath().toOSString()), file);
+ classpathUndo
+ .setEdit(new ReplaceEdit(0, getFileLength(file), contents));
result.add(classpathUndo);
}
result.add(new UndoDeleteResourceChange(rootDescription));
@@ -146,14 +145,17 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
}
private boolean confirmDeleteIfReferenced() throws ModelException {
- if (! getRoot().isArchive()) //for source folders, you don't ask, just do it
+ if (!getRoot().isArchive()) // for source folders, you don't ask, just
+ // do it
return true;
if (fUpdateClasspathQuery == null)
return true;
- IScriptProject[] referencingProjects= ModelElementUtil.getReferencingProjects(getRoot());
+ IScriptProject[] referencingProjects = ModelElementUtil
+ .getReferencingProjects(getRoot());
if (referencingProjects.length == 0)
return true;
- return fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
+ return fUpdateClasspathQuery.confirmManipulation(getRoot(),
+ referencingProjects);
}
private static int getFileLength(IFile file) throws CoreException {
@@ -170,8 +172,8 @@ public class DeleteProjectFragmentChange extends AbstractDeleteChange {
try {
return (int) reader.skip(Integer.MAX_VALUE);
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, DLTKUIPlugin
- .getPluginId(), e.getMessage(), e));
+ throw new CoreException(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), e.getMessage(), e));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java
index be091926d..638617818 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.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
@@ -55,12 +55,10 @@ public class DeleteSourceManipulationChange extends AbstractDeleteChange {
// don't check anything in this case. We have a warning dialog
// already presented to the user that the file is dirty.
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, DIRTY);
}
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
+ return super.isValid(pm, DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
private String getElementName() {
@@ -100,9 +98,8 @@ public class DeleteSourceManipulationChange extends AbstractDeleteChange {
resourceDescription.recordStateFromHistory(resource,
new SubProgressMonitor(pm, 1));
return new UndoDeleteResourceChange(resourceDescription);
- } else {
- element.delete(false, pm);
}
+ element.delete(false, pm);
return null;
// begin fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=66835
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java
index cedc0744b..1a7c5b007 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.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,65 +18,69 @@ import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class MoveSourceModuleChange extends SourceModuleReorgChange {
private boolean fUndoable;
private long fStampToRestore;
-
- public MoveSourceModuleChange(ISourceModule cu, IScriptFolder newPackage){
+
+ public MoveSourceModuleChange(ISourceModule cu, IScriptFolder newPackage) {
super(cu, newPackage);
- fStampToRestore= IResource.NULL_STAMP;
+ fStampToRestore = IResource.NULL_STAMP;
}
-
- private MoveSourceModuleChange(IScriptFolder oldPackage, String cuName, IScriptFolder newPackage, long stampToRestore) {
- super(oldPackage.getHandleIdentifier(), newPackage.getHandleIdentifier(), oldPackage.getSourceModule(cuName).getHandleIdentifier());
- fStampToRestore= stampToRestore;
+
+ private MoveSourceModuleChange(IScriptFolder oldPackage, String cuName,
+ IScriptFolder newPackage, long stampToRestore) {
+ super(oldPackage.getHandleIdentifier(),
+ newPackage.getHandleIdentifier(),
+ oldPackage.getSourceModule(cuName).getHandleIdentifier());
+ fStampToRestore = stampToRestore;
}
-
+
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.MoveSourceModuleChange_name,
- new String[]{getCu().getElementName(), getPackageName(getDestinationPackage())});
+ return Messages.format(
+ RefactoringCoreMessages.MoveSourceModuleChange_name,
+ getCu().getElementName(),
+ getPackageName(getDestinationPackage()));
}
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
return super.isValid(pm, READ_ONLY | SAVE_IF_DIRTY);
}
-
+
@Override
Change doPerformReorg(IProgressMonitor pm) throws CoreException {
String name;
- String newName= getNewName();
+ String newName = getNewName();
if (newName == null)
- name= getCu().getElementName();
+ name = getCu().getElementName();
else
- name= newName;
-
+ name = newName;
+
// get current modification stamp
- long currentStamp= IResource.NULL_STAMP;
- IResource resource= getCu().getResource();
+ long currentStamp = IResource.NULL_STAMP;
+ IResource resource = getCu().getResource();
if (resource != null) {
- currentStamp= resource.getModificationStamp();
+ currentStamp = resource.getModificationStamp();
}
-
- fUndoable= ! getDestinationPackage().getSourceModule(name).exists();
-
+
+ fUndoable = !getDestinationPackage().getSourceModule(name).exists();
+
// perform the move and restore modification stamp
getCu().move(getDestinationPackage(), null, newName, true, pm);
if (fStampToRestore != IResource.NULL_STAMP) {
- ISourceModule moved= getDestinationPackage().getSourceModule(name);
- IResource movedResource= moved.getResource();
+ ISourceModule moved = getDestinationPackage().getSourceModule(name);
+ IResource movedResource = moved.getResource();
if (movedResource != null) {
movedResource.revertModificationStamp(fStampToRestore);
}
}
-
+
if (fUndoable) {
- return new MoveSourceModuleChange(getDestinationPackage(), getCu().getElementName(), getOldPackage(), currentStamp);
- } else {
- return null;
+ return new MoveSourceModuleChange(getDestinationPackage(),
+ getCu().getElementName(), getOldPackage(), currentStamp);
}
+ return null;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
index 62fa01d16..f453c23a8 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
@@ -130,10 +129,10 @@ abstract class ProjectFragmentReorgChange extends DLTKChange {
boolean updateOtherProjectsToo = fUpdateBuildpathQuery
.confirmManipulation(getRoot(), referencingProjects);
- if (updateOtherProjectsToo)
+ if (updateOtherProjectsToo) {
return replace | originating | destination | otherProjects;
- else
- return replace | originating | destination;
+ }
+ return replace | originating | destination;
}
protected int getResourceUpdateFlags() {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java
index f8667fa25..4317b8d35 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.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
@@ -22,7 +22,6 @@ import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public final class RenameResourceChange extends DLTKChange {
public static IPath renamedResourcePath(IPath path, String newName) {
@@ -39,16 +38,20 @@ public final class RenameResourceChange extends DLTKChange {
private final long fStampToRestore;
- private RenameResourceChange(RefactoringDescriptor descriptor, IPath resourcePath, String newName, String comment, long stampToRestore) {
- fDescriptor= descriptor;
- fResourcePath= resourcePath;
- fNewName= newName;
- fComment= comment;
- fStampToRestore= stampToRestore;
+ private RenameResourceChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String newName, String comment,
+ long stampToRestore) {
+ fDescriptor = descriptor;
+ fResourcePath = resourcePath;
+ fNewName = newName;
+ fComment = comment;
+ fStampToRestore = stampToRestore;
}
- public RenameResourceChange(RefactoringDescriptor descriptor, IResource resource, String newName, String comment) {
- this(descriptor, resource.getFullPath(), newName, comment, IResource.NULL_STAMP);
+ public RenameResourceChange(RefactoringDescriptor descriptor,
+ IResource resource, String newName, String comment) {
+ this(descriptor, resource.getFullPath(), newName, comment,
+ IResource.NULL_STAMP);
}
@Override
@@ -65,7 +68,9 @@ public final class RenameResourceChange extends DLTKChange {
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameResourceChange_name, new String[] { fResourcePath.toString(), fNewName});
+ return Messages.format(
+ RefactoringCoreMessages.RenameResourceChange_name,
+ fResourcePath.toString(), fNewName);
}
public String getNewName() {
@@ -73,34 +78,40 @@ public final class RenameResourceChange extends DLTKChange {
}
private IResource getResource() {
- return ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath);
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(fResourcePath);
}
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
- IResource resource= getResource();
+ IResource resource = getResource();
if (resource == null || !resource.exists()) {
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.RenameResourceChange_does_not_exist, fResourcePath.toString()));
- } else {
- return super.isValid(pm, DIRTY);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.RenameResourceChange_does_not_exist,
+ fResourcePath.toString()));
}
+ return super.isValid(pm, DIRTY);
}
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
try {
- pm.beginTask(RefactoringCoreMessages.RenameResourceChange_rename_resource, 1);
+ pm.beginTask(
+ RefactoringCoreMessages.RenameResourceChange_rename_resource,
+ 1);
- IResource resource= getResource();
- long currentStamp= resource.getModificationStamp();
- IPath newPath= renamedResourcePath(fResourcePath, fNewName);
+ IResource resource = getResource();
+ long currentStamp = resource.getModificationStamp();
+ IPath newPath = renamedResourcePath(fResourcePath, fNewName);
resource.move(newPath, IResource.SHALLOW, pm);
if (fStampToRestore != IResource.NULL_STAMP) {
- IResource newResource= ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
+ IResource newResource = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(newPath);
newResource.revertModificationStamp(fStampToRestore);
}
- String oldName= fResourcePath.lastSegment();
- return new RenameResourceChange(null, newPath, oldName, fComment, currentStamp);
+ String oldName = fResourcePath.lastSegment();
+ return new RenameResourceChange(null, newPath, oldName, fComment,
+ currentStamp);
} finally {
pm.done();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java
index aa0d227b1..a1fd30294 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.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
@@ -22,22 +22,27 @@ import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+public final class RenameSourceFolderChange
+ extends AbstractModelElementRenameChange {
-public final class RenameSourceFolderChange extends AbstractModelElementRenameChange {
-
- private static RefactoringStatus checkIfModifiable(IProjectFragment root, IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= new RefactoringStatus();
+ private static RefactoringStatus checkIfModifiable(IProjectFragment root,
+ IProgressMonitor pm) throws CoreException {
+ RefactoringStatus result = new RefactoringStatus();
checkExistence(result, root);
if (result.hasFatalError())
return result;
if (root.isArchive()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_archive, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_archive,
+ root.getElementName()));
return result;
}
if (root.isExternal()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_external, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_external,
+ root.getElementName()));
return result;
}
@@ -46,20 +51,26 @@ public final class RenameSourceFolderChange extends AbstractModelElementRenameCh
return result;
if (root.getCorrespondingResource().isLinked()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_linked, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_linked,
+ root.getElementName()));
return result;
}
return result;
}
- public RenameSourceFolderChange(RefactoringDescriptor descriptor, IProjectFragment sourceFolder, String newName, String comment) {
- this(descriptor, sourceFolder.getPath(), sourceFolder.getElementName(), newName, comment, IResource.NULL_STAMP);
+ public RenameSourceFolderChange(RefactoringDescriptor descriptor,
+ IProjectFragment sourceFolder, String newName, String comment) {
+ this(descriptor, sourceFolder.getPath(), sourceFolder.getElementName(),
+ newName, comment, IResource.NULL_STAMP);
Assert.isTrue(!sourceFolder.isReadOnly(), "should not be read only"); //$NON-NLS-1$
Assert.isTrue(!sourceFolder.isArchive(), "should not be an archive"); //$NON-NLS-1$
}
- private RenameSourceFolderChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore) {
+ private RenameSourceFolderChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String oldName, String newName, String comment,
+ long stampToRestore) {
super(descriptor, resourcePath, oldName, newName, comment);
}
@@ -70,34 +81,42 @@ public final class RenameSourceFolderChange extends AbstractModelElementRenameCh
@Override
protected Change createUndoChange(long stampToRestore) {
- return new RenameSourceFolderChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore);
+ return new RenameSourceFolderChange(null, createNewPath(), getNewName(),
+ getOldName(), getComment(), stampToRestore);
}
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- IProjectFragment sourceFolder= getSourceFolder();
+ IProjectFragment sourceFolder = getSourceFolder();
if (sourceFolder != null)
- sourceFolder.move(getNewPath(), getCoreMoveFlags(), getScriptModelUpdateFlags(), null, pm);
+ sourceFolder.move(getNewPath(), getCoreMoveFlags(),
+ getScriptModelUpdateFlags(), null, pm);
}
private int getCoreMoveFlags() {
- if (getResource().isLinked())
+ if (getResource().isLinked()) {
return IResource.SHALLOW;
- else
- return IResource.NONE;
+ }
+ return IResource.NONE;
}
private int getScriptModelUpdateFlags() {
- return IProjectFragment.DESTINATION_PROJECT_BUILDPATH | IProjectFragment.ORIGINATING_PROJECT_BUILDPATH | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH | IProjectFragment.REPLACE;
+ return IProjectFragment.DESTINATION_PROJECT_BUILDPATH
+ | IProjectFragment.ORIGINATING_PROJECT_BUILDPATH
+ | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH
+ | IProjectFragment.REPLACE;
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename, new String[] { getOldName(), getNewName()});
+ return Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename,
+ getOldName(), getNewName());
}
private IPath getNewPath() {
- return getResource().getFullPath().removeLastSegments(1).append(getNewName());
+ return getResource().getFullPath().removeLastSegments(1)
+ .append(getNewName());
}
private IProjectFragment getSourceFolder() {
@@ -106,13 +125,14 @@ public final class RenameSourceFolderChange extends AbstractModelElementRenameCh
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= new RefactoringStatus();
+ RefactoringStatus result = new RefactoringStatus();
pm.beginTask("", 2); //$NON-NLS-1$
result.merge(isValid(new SubProgressMonitor(pm, 1), DIRTY));
if (result.hasFatalError())
return result;
- IProjectFragment sourceFolder= getSourceFolder();
- result.merge(checkIfModifiable(sourceFolder, new SubProgressMonitor(pm, 1)));
+ IProjectFragment sourceFolder = getSourceFolder();
+ result.merge(
+ checkIfModifiable(sourceFolder, new SubProgressMonitor(pm, 1)));
return result;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java
index 8452bb5f1..8a77d6094 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.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,41 +23,52 @@ import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+public final class RenameSourceModuleChange
+ extends AbstractModelElementRenameChange {
-public final class RenameSourceModuleChange extends AbstractModelElementRenameChange {
-
- public RenameSourceModuleChange(RefactoringDescriptor descriptor, ISourceModule unit, String newName, String comment) {
- this(descriptor, ResourceUtil.getResource(unit).getFullPath(), unit.getElementName(), newName, comment, IResource.NULL_STAMP);
- Assert.isTrue(!unit.isReadOnly(), "compilation unit must not be read-only"); //$NON-NLS-1$
+ public RenameSourceModuleChange(RefactoringDescriptor descriptor,
+ ISourceModule unit, String newName, String comment) {
+ this(descriptor, ResourceUtil.getResource(unit).getFullPath(),
+ unit.getElementName(), newName, comment, IResource.NULL_STAMP);
+ Assert.isTrue(!unit.isReadOnly(),
+ "compilation unit must not be read-only"); //$NON-NLS-1$
}
- private RenameSourceModuleChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore) {
- super(descriptor, resourcePath, oldName, newName, comment, stampToRestore);
+ private RenameSourceModuleChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String oldName, String newName, String comment,
+ long stampToRestore) {
+ super(descriptor, resourcePath, oldName, newName, comment,
+ stampToRestore);
}
@Override
protected IPath createNewPath() {
- if (getResourcePath().getFileExtension() != null)
- return getResourcePath().removeFileExtension().removeLastSegments(1).append(getNewName());
- else
- return getResourcePath().removeLastSegments(1).append(getNewName());
+ if (getResourcePath().getFileExtension() != null) {
+ return getResourcePath().removeFileExtension().removeLastSegments(1)
+ .append(getNewName());
+ }
+ return getResourcePath().removeLastSegments(1).append(getNewName());
}
@Override
- protected Change createUndoChange(long stampToRestore) throws ModelException {
- return new RenameSourceModuleChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore);
+ protected Change createUndoChange(long stampToRestore)
+ throws ModelException {
+ return new RenameSourceModuleChange(null, createNewPath(), getNewName(),
+ getOldName(), getComment(), stampToRestore);
}
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- ISourceModule cu= (ISourceModule) getModifiedElement();
+ ISourceModule cu = (ISourceModule) getModifiedElement();
if (cu != null)
cu.rename(getNewName(), false, pm);
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameSourceModuleChange_name, new String[] { getOldName(), getNewName()});
+ return Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_name,
+ getOldName(), getNewName());
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java
index be0ce2b2d..8273b13f8 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.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
@@ -125,17 +125,17 @@ abstract class ResourceReorgChange extends DLTKChange {
}
protected IResource getResource() {
- if (fIsFile)
+ if (fIsFile) {
return getFile();
- else
- return getFolder();
+ }
+ return getFolder();
}
IContainer getDestination() {
- if (fIsDestinationProject)
+ if (fIsDestinationProject) {
return Utils.getProject(fDestinationPath);
- else
- return Utils.getFolder(fDestinationPath);
+ }
+ return Utils.getFolder(fDestinationPath);
}
protected int getReorgFlags() {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java
index 7a2568c7b..95e55f6ab 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.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
@@ -89,10 +89,10 @@ abstract class SourceModuleReorgChange extends DLTKChange {
}
static String getPackageName(IScriptFolder pack) {
- if (pack.isRootFolder())
+ if (pack.isRootFolder()) {
return RefactoringCoreMessages.MoveSourceModuleChange_default_package;
- else
- return pack.getElementName();
+ }
+ return pack.getElementName();
}
private void markAsExecuted(ISourceModule unit, ResourceMapping mapping) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
index a0a1d5590..fb7f2aea9 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.corext.refactoring.changes;
@@ -18,66 +17,66 @@ import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup;
-
/**
- * A utility class to provide compatibility with the old
- * text change API of adding text edits directly and auto
- * inserting them into the tree.
+ * A utility class to provide compatibility with the old text change API of
+ * adding text edits directly and auto inserting them into the tree.
*/
public class TextChangeCompatibility {
- public static void addTextEdit(TextChange change, String name, TextEdit edit) {
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit edit) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edit);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
insert(root, edit);
change.addTextEditGroup(new TextEditGroup(name, edit));
}
-
- public static void addTextEdit(TextChange change, String name, TextEdit edit, GroupCategorySet groupCategories) {
+
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit edit, GroupCategorySet groupCategories) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edit);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
insert(root, edit);
- change.addTextEditChangeGroup(new TextEditChangeGroup(
- change,
- new CategorizedTextEditGroup(name, edit, groupCategories)));
+ change.addTextEditChangeGroup(new TextEditChangeGroup(change,
+ new CategorizedTextEditGroup(name, edit, groupCategories)));
}
-
- public static void addTextEdit(TextChange change, String name, TextEdit[] edits) {
+
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit[] edits) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edits);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
- for (int i= 0; i < edits.length; i++) {
+ for (int i = 0; i < edits.length; i++) {
insert(root, edits[i]);
}
change.addTextEditGroup(new TextEditGroup(name, edits));
}
-
+
public static void insert(TextEdit parent, TextEdit edit) {
if (!parent.hasChildren()) {
parent.addChild(edit);
return;
}
- TextEdit[] children= parent.getChildren();
+ TextEdit[] children = parent.getChildren();
// First dive down to find the right parent.
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
+ for (int i = 0; i < children.length; i++) {
+ TextEdit child = children[i];
if (covers(child, edit)) {
insert(child, edit);
return;
@@ -85,9 +84,9 @@ public class TextChangeCompatibility {
}
// We have the right parent. Now check if some of the children have to
// be moved under the new edit since it is covering it.
- int removed= 0;
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
+ int removed = 0;
+ for (int i = 0; i < children.length; i++) {
+ TextEdit child = children[i];
if (covers(edit, child)) {
parent.removeChild(i - removed++);
edit.addChild(child);
@@ -95,21 +94,21 @@ public class TextChangeCompatibility {
}
parent.addChild(edit);
}
-
+
private static boolean covers(TextEdit thisEdit, TextEdit otherEdit) {
- if (thisEdit.getLength() == 0) // an insertion point can't cover anything
+ if (thisEdit.getLength() == 0) // an insertion point can't cover
+ // anything
return false;
-
- int thisOffset= thisEdit.getOffset();
- int thisEnd= thisEdit.getExclusiveEnd();
+
+ int thisOffset = thisEdit.getOffset();
+ int thisEnd = thisEdit.getExclusiveEnd();
if (otherEdit.getLength() == 0) {
- int otherOffset= otherEdit.getOffset();
+ int otherOffset = otherEdit.getOffset();
return thisOffset < otherOffset && otherOffset < thisEnd;
- } else {
- int otherOffset= otherEdit.getOffset();
- int otherEnd= otherEdit.getExclusiveEnd();
- return thisOffset <= otherOffset && otherEnd <= thisEnd;
}
- }
-
+ int otherOffset = otherEdit.getOffset();
+ int otherEnd = otherEdit.getExclusiveEnd();
+ return thisOffset <= otherOffset && otherEnd <= thisEnd;
+ }
+
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java
index a29c90043..c56296fdb 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.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
@@ -73,11 +73,11 @@ public class CreateFileChange extends DLTKChange {
@Override
public String getName() {
- if (fChangeName == null)
+ if (fChangeName == null) {
return Messages.format(NLSChangesMessages.createFile_Create_file,
fPath.toOSString());
- else
- return fChangeName;
+ }
+ return fChangeName;
}
public void setName(String name) {
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 1de29da99..b6ccb9d3d 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
@@ -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
@@ -89,10 +89,10 @@ public class RenameScriptFolderProcessor extends ScriptRenameProcessor
/**
* Creates a new rename package processor.
- *
+ *
* @param fragment
- * the package fragment, or <code>null</code> if invoked by
- * scripting
+ * the package fragment, or <code>null</code> if invoked
+ * by scripting
*/
public RenameScriptFolderProcessor(IScriptFolder fragment) {
fPackage = fragment;
@@ -380,11 +380,11 @@ public class RenameScriptFolderProcessor extends ScriptRenameProcessor
private RefactoringStatus checkPackageInCurrentRoot(String newName)
throws CoreException {
- if (isPackageNameOkInRoot(newName, getProjectFragment()))
+ if (isPackageNameOkInRoot(newName, getProjectFragment())) {
return null;
- else
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
+ }
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
}
private IProjectFragment getProjectFragment() {
@@ -452,7 +452,7 @@ public class RenameScriptFolderProcessor extends ScriptRenameProcessor
for (int i = 0; i < types.length; i++) {
String name = types[i].getElementName();
if (topLevelTypeNames.contains(name)) {
- String[] keys = { packageName, name };
+ Object[] keys = { packageName, name };
String msg = Messages.format(
RefactoringCoreMessages.RenamePackageRefactoring_contains_type,
keys);
@@ -699,11 +699,11 @@ public class RenameScriptFolderProcessor extends ScriptRenameProcessor
final IModelElement element = ScriptRefactoringDescriptor
.handleToElement(extended.getProject(), handle, false);
if (element == null || !element.exists() || element
- .getElementType() != IModelElement.SCRIPT_FOLDER)
+ .getElementType() != IModelElement.SCRIPT_FOLDER) {
return ScriptableRefactoring.createInputFatalStatus(element,
getRefactoring().getName(), ID_RENAME_PACKAGE);
- else
- fPackage = (IScriptFolder) element;
+ }
+ fPackage = (IScriptFolder) element;
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
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 46cc326a7..b15351e79 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
@@ -44,26 +44,29 @@ import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
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$
+ 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$
private IScriptProject fProject;
private boolean fUpdateReferences;
- public static final String IDENTIFIER= "org.eclipse.dltk.ui.renameScriptProjectProcessor"; //$NON-NLS-1$
+ public static final String IDENTIFIER = "org.eclipse.dltk.ui.renameScriptProjectProcessor"; //$NON-NLS-1$
/**
* 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;
+ fProject = project;
if (fProject != null)
setNewElementName(fProject.getElementName());
- fUpdateReferences= true;
+ fUpdateReferences = true;
}
@Override
@@ -88,33 +91,37 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
@Override
public Object[] getElements() {
- return new Object[] {fProject};
+ return new Object[] { fProject };
}
@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 {
- RenameModifications result= new RenameModifications();
- result.rename(fProject, new RenameArguments(getNewElementName(), getUpdateReferences()));
+ protected RenameModifications computeRenameModifications()
+ throws CoreException {
+ RenameModifications result = new RenameModifications();
+ 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};
+ return new IFile[] { projectFile };
}
return new IFile[0];
}
- //---- IReferenceUpdating --------------------------------------
+ // ---- IReferenceUpdating --------------------------------------
@Override
public boolean canEnableUpdateReferences() {
@@ -123,7 +130,7 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
@Override
public void setUpdateReferences(boolean update) {
- fUpdateReferences= update;
+ fUpdateReferences = update;
}
@Override
@@ -131,7 +138,7 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
return fUpdateReferences;
}
- //---- IRenameProcessor ----------------------------------------------
+ // ---- IRenameProcessor ----------------------------------------------
@Override
public String getCurrentElementName() {
@@ -139,36 +146,43 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
}
@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,
- fProject.getElementName());
+ try {
+ if (isReadOnly()) {
+ String message = Messages.format(
+ RefactoringCoreMessages.RenameScriptProjectRefactoring_read_only,
+ fProject.getElementName());
return RefactoringStatus.createErrorStatus(message);
}
return new RefactoringStatus();
- } finally{
+ } finally {
pm.done();
}
}
@@ -177,35 +191,54 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
return Resources.isReadOnly(fProject.getResource());
}
- private boolean projectNameAlreadyExists(String newName){
- return ResourcesPlugin.getWorkspace().getRoot().getProject(newName).exists();
+ private boolean projectNameAlreadyExists(String newName) {
+ 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();
- IFileStore projectStore= EFS.getStore(locationURI);
- IFileStore newProjectStore= projectStore.getParent().getChild(newName);
+ URI locationURI = fProject.getProject().getLocationURI();
+ IFileStore projectStore = EFS.getStore(locationURI);
+ IFileStore newProjectStore = projectStore.getParent().getChild(newName);
return newProjectStore.fetchInfo().exists();
}
- //--- changes
+ // --- changes
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
- final Map arguments= new HashMap();
- final String description= Messages.format(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, getNewElementName());
- arguments.put(ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
- return new DynamicValidationStateChange(new RenameScriptProjectChange(descriptor, fProject, getNewElementName(), comment, fUpdateReferences));
+ final Map arguments = new HashMap();
+ final String description = Messages.format(
+ 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,
+ getNewElementName());
+ arguments.put(ATTRIBUTE_REFERENCES,
+ Boolean.valueOf(fUpdateReferences).toString());
+ return new DynamicValidationStateChange(
+ new RenameScriptProjectChange(descriptor, fProject,
+ getNewElementName(), comment, fUpdateReferences));
} finally {
pm.done();
}
@@ -214,28 +247,42 @@ public class RenameScriptProjectProcessor extends ScriptRenameProcessor implemen
@Override
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
- final ScriptRefactoringArguments extended= (ScriptRefactoringArguments) arguments;
- final String handle= extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
+ final ScriptRefactoringArguments extended = (ScriptRefactoringArguments) arguments;
+ 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(), ID_RENAME_SCRIPT_PROJECT);
- else
- fProject= (IScriptProject) element;
+ 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();
+ fUpdateReferences = Boolean.valueOf(references).booleanValue();
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REFERENCES));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ 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/rename/RenameSourceFolderProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java
index 7be1724da..f1047376c 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.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
@@ -40,23 +40,25 @@ import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-
public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
- private static final String ID_RENAME_SOURCE_FOLDER= "org.eclipse.dltk.ui.rename.source.folder"; //$NON-NLS-1$
- private static final String ATTRIBUTE_PATH= "path"; //$NON-NLS-1$
- private static final String ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
+ private static final String ID_RENAME_SOURCE_FOLDER = "org.eclipse.dltk.ui.rename.source.folder"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
private IProjectFragment fSourceFolder;
- public static final String IDENTIFIER= "org.eclipse.dltk.ui.renameSourceFolderProcessor"; //$NON-NLS-1$
+ public static final String IDENTIFIER = "org.eclipse.dltk.ui.renameSourceFolderProcessor"; //$NON-NLS-1$
/**
* Creates a new rename source folder processor.
- * @param root the package fragment root, or <code>null</code> if invoked by scripting
+ *
+ * @param root
+ * the package fragment root, or <code>null</code> if
+ * invoked by scripting
*/
public RenameSourceFolderProcessor(IProjectFragment root) {
- fSourceFolder= root;
+ fSourceFolder = root;
if (root != null)
setNewElementName(root.getElementName());
}
@@ -83,13 +85,14 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
@Override
public Object[] getElements() {
- return new Object[] {fSourceFolder};
+ return new Object[] { fSourceFolder };
}
@Override
public Object getNewElement() throws CoreException {
- IProjectFragment[] roots= fSourceFolder.getScriptProject().getProjectFragments();
- for (int i= 0; i < roots.length; i++) {
+ IProjectFragment[] roots = fSourceFolder.getScriptProject()
+ .getProjectFragments();
+ for (int i = 0; i < roots.length; i++) {
if (roots[i].getElementName().equals(getNewElementName()))
return roots[i];
}
@@ -97,9 +100,11 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
}
@Override
- protected RenameModifications computeRenameModifications() throws CoreException {
- RenameModifications result= new RenameModifications();
- result.rename(fSourceFolder, new RenameArguments(getNewElementName(), getUpdateReferences()));
+ protected RenameModifications computeRenameModifications()
+ throws CoreException {
+ RenameModifications result = new RenameModifications();
+ result.rename(fSourceFolder, new RenameArguments(getNewElementName(),
+ getUpdateReferences()));
return result;
}
@@ -108,7 +113,7 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
return new IFile[0];
}
- //---- IRenameProcessor ----------------------------------------------
+ // ---- IRenameProcessor ----------------------------------------------
@Override
public String getCurrentElementName() {
@@ -116,48 +121,58 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
}
@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$
- if (! newName.trim().equals(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
+ if (!newName.trim().equals(newName))
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
- IContainer c= fSourceFolder.getResource().getParent();
- if (! c.getFullPath().isValidSegment(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
+ IContainer c = fSourceFolder.getResource().getParent();
+ if (!c.getFullPath().isValidSegment(newName))
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
- RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER));
+ RefactoringStatus result = RefactoringStatus.create(
+ c.getWorkspace().validateName(newName, IResource.FOLDER));
if (result.hasFatalError())
return result;
- result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER)));
+ result.merge(RefactoringStatus.create(c.getWorkspace()
+ .validatePath(createNewPath(newName), IResource.FOLDER)));
if (result.hasFatalError())
return result;
- IScriptProject project= fSourceFolder.getScriptProject();
- IPath p= project.getProject().getFullPath().append(newName);
+ IScriptProject project = fSourceFolder.getScriptProject();
+ IPath p = project.getProject().getFullPath().append(newName);
if (project.findProjectFragment(p) != null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
if (project.getProject().findMember(new Path(newName)) != null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
return result;
}
private String createNewPath(String newName) {
- return fSourceFolder.getPath().removeLastSegments(1).append(newName).toString();
+ return fSourceFolder.getPath().removeLastSegments(1).append(newName)
+ .toString();
}
@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{
+ try {
return new RefactoringStatus();
- } finally{
+ } finally {
pm.done();
}
}
@@ -170,17 +185,27 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
public Change createChange(IProgressMonitor pm) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
- final Map arguments= new HashMap();
- final IResource resource= fSourceFolder.getResource();
- final String project= resource.getProject().getName();
- final String newName= getNewElementName();
- final String description= Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description_short, fSourceFolder.getElementName());
- final String header= Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description, new String[] { resource.getFullPath().toString(), newName});
- final String comment= new ScriptRefactoringDescriptorComment(this, header).asString();
- final ScriptRefactoringDescriptor descriptor= new ScriptRefactoringDescriptor(ID_RENAME_SOURCE_FOLDER, project, description, comment, arguments, RefactoringDescriptor.NONE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor.elementToHandle(DLTKCore.create(resource)));
+ final Map arguments = new HashMap();
+ final IResource resource = fSourceFolder.getResource();
+ final String project = resource.getProject().getName();
+ final String newName = getNewElementName();
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description_short,
+ fSourceFolder.getElementName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description,
+ resource.getFullPath().toString(), newName);
+ final String comment = new ScriptRefactoringDescriptorComment(this,
+ header).asString();
+ final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
+ ID_RENAME_SOURCE_FOLDER, project, description, comment,
+ arguments, RefactoringDescriptor.NONE);
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
+ descriptor.elementToHandle(DLTKCore.create(resource)));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
- return new DynamicValidationStateChange(new RenameSourceFolderChange(descriptor, fSourceFolder, newName, comment));
+ return new DynamicValidationStateChange(
+ new RenameSourceFolderChange(descriptor, fSourceFolder,
+ newName, comment));
} finally {
pm.done();
}
@@ -189,23 +214,31 @@ public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
@Override
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
- final ScriptRefactoringArguments generic= (ScriptRefactoringArguments) arguments;
- final String path= generic.getAttribute(ATTRIBUTE_PATH);
+ final ScriptRefactoringArguments generic = (ScriptRefactoringArguments) arguments;
+ final String path = generic.getAttribute(ATTRIBUTE_PATH);
if (path != null) {
- final IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
- if (resource == null || !resource.exists())
- return ScriptableRefactoring.createInputFatalStatus(resource, getRefactoring().getName(), ID_RENAME_SOURCE_FOLDER);
- else
- fSourceFolder= (IProjectFragment) DLTKCore.create(resource);
+ final IResource resource = ResourcesPlugin.getWorkspace()
+ .getRoot().findMember(new Path(path));
+ if (resource == null || !resource.exists()) {
+ return ScriptableRefactoring.createInputFatalStatus(
+ resource, getRefactoring().getName(),
+ ID_RENAME_SOURCE_FOLDER);
+ }
+ fSourceFolder = (IProjectFragment) DLTKCore.create(resource);
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_PATH));
- final String name= generic.getAttribute(ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_PATH));
+ final String name = generic.getAttribute(ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ 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/RenameSourceModuleProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java
index 04ab7aea4..ba689708e 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.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
@@ -69,11 +69,12 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
* Creates a new rename compilation unit processor.
*
* @param unit
- * the compilation unit, or <code>null</code> if invoked by
- * scripting
+ * the compilation unit, or <code>null</code> if invoked by
+ * scripting
* @throws CoreException
*/
- public RenameSourceModuleProcessor(ISourceModule unit) throws CoreException {
+ public RenameSourceModuleProcessor(ISourceModule unit)
+ throws CoreException {
fCu = unit;
if (fCu != null) {
computeRenameTypeRefactoring();
@@ -133,10 +134,9 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
if (isFileExtensionRequired()) {
// return initial name without extension
return getSimpleCUName();
- } else {
- // return initial name with extension
- return fCu.getElementName();
}
+ // return initial name with extension
+ return fCu.getElementName();
}
/**
@@ -166,8 +166,8 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
}
RefactoringStatus result = new RefactoringStatus();// Checks.checkSourceModuleName(newName);
if (Checks.isAlreadyNamed(fCu, newName))
- result
- .addFatalError(RefactoringCoreMessages.RenameSourceModuleRefactoring_same_name);
+ result.addFatalError(
+ RefactoringCoreMessages.RenameSourceModuleRefactoring_same_name);
return result;
}
@@ -184,9 +184,8 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
IScriptFolder pack = (IScriptFolder) parent;
IDLTKLanguageToolkit tk = null;
tk = DLTKLanguageManager.getLanguageToolkit(pack);
- if (tk != null
- && !DLTKContentTypeManager.isValidFileNameForContentType(tk,
- getNewElementName())) {
+ if (tk != null && !DLTKContentTypeManager
+ .isValidFileNameForContentType(tk, getNewElementName())) {
return fCu; // ??
}
return pack.getSourceModule(getNewElementName());
@@ -341,28 +340,23 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
final Map arguments = new HashMap();
final IProject project = resource.getProject();
final String name = project.getName();
- final String description = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
- resource.getName());
- final String header = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
- new String[] { resource.getFullPath().toString(),
- newName });
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
+ resource.getName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
+ resource.getFullPath().toString(), newName);
final String comment = new ScriptRefactoringDescriptorComment(this,
header).asString();
final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
- RenameResourceProcessor.ID_RENAME_RESOURCE,
- name,
- description,
- comment,
- arguments,
+ RenameResourceProcessor.ID_RENAME_RESOURCE, name,
+ description, comment, arguments,
(RefactoringDescriptor.STRUCTURAL_CHANGE
- | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE));
+ | RefactoringDescriptor.MULTI_CHANGE
+ | RefactoringDescriptor.BREAKING_CHANGE));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
- ScriptRefactoringDescriptor
- .resourceToHandle(name, resource));
+ ScriptRefactoringDescriptor.resourceToHandle(name,
+ resource));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
return new DynamicValidationStateChange(new RenameResourceChange(
descriptor, resource, newName, comment));
@@ -378,14 +372,12 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
label = fCu.getElementName();
final Map arguments = new HashMap();
final String name = fCu.getScriptProject().getElementName();
- final String description = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
- fCu.getElementName());
- final String header = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
- new String[] { label, newName });
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
+ fCu.getElementName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
+ label, newName);
final String comment = new ScriptRefactoringDescriptorComment(this,
header).asString();
final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
@@ -395,8 +387,8 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
| ScriptRefactoringDescriptor.ARCHIVE_REFACTORABLE
| RefactoringDescriptor.STRUCTURAL_CHANGE
| RefactoringDescriptor.MULTI_CHANGE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor
- .elementToHandle(fCu));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
+ descriptor.elementToHandle(fCu));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
return new DynamicValidationStateChange(new RenameSourceModuleChange(
descriptor, fCu, newName, comment));
@@ -419,36 +411,31 @@ public class RenameSourceModuleProcessor extends ScriptRenameProcessor
if (path != null) {
final IResource resource = ResourcesPlugin.getWorkspace()
.getRoot().findMember(new Path(path));
- if (resource == null || !resource.exists())
+ if (resource == null || !resource.exists()) {
return ScriptableRefactoring.createInputFatalStatus(
resource, getRefactoring().getName(),
ID_RENAME_COMPILATION_UNIT);
- else {
- fCu = (ISourceModule) DLTKCore.create(resource);
- try {
- computeRenameTypeRefactoring();
- } catch (CoreException exception) {
- DLTKUIPlugin.log(exception);
- }
+ }
+ fCu = (ISourceModule) DLTKCore.create(resource);
+ try {
+ computeRenameTypeRefactoring();
+ } catch (CoreException exception) {
+ DLTKUIPlugin.log(exception);
}
} else
- return RefactoringStatus
- .createFatalErrorStatus(Messages
- .format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_PATH));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_PATH));
final String name = generic.getAttribute(ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus
- .createFatalErrorStatus(Messages
- .format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ 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/RenamingNameSuggestor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java
index f7931f3d0..8d526a812 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.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
@@ -176,13 +176,13 @@ public class RenamingNameSuggestor {
initializePrefixesAndSuffixes(project);
- if (isStatic)
+ if (isStatic) {
return suggestNewVariableName(fStaticFieldPrefixes,
fStaticFieldSuffixes, oldFieldName, oldTypeName,
newTypeName);
- else
- return suggestNewVariableName(fFieldPrefixes, fFieldSuffixes,
- oldFieldName, oldTypeName, newTypeName);
+ }
+ return suggestNewVariableName(fFieldPrefixes, fFieldSuffixes,
+ oldFieldName, oldTypeName, newTypeName);
}
public String suggestNewLocalName(IScriptProject project,
@@ -191,12 +191,12 @@ public class RenamingNameSuggestor {
initializePrefixesAndSuffixes(project);
- if (isArgument)
+ if (isArgument) {
return suggestNewVariableName(fArgumentPrefixes, fArgumentSuffixes,
oldLocalName, oldTypeName, newTypeName);
- else
- return suggestNewVariableName(fLocalPrefixes, fLocalSuffixes,
- oldLocalName, oldTypeName, newTypeName);
+ }
+ return suggestNewVariableName(fLocalPrefixes, fLocalSuffixes,
+ oldLocalName, oldTypeName, newTypeName);
}
public String suggestNewMethodName(String oldMethodName, String oldTypeName,
@@ -443,10 +443,10 @@ public class RenamingNameSuggestor {
}
String varName = concat(suffixesVar);
- if (varName.equals(strippedVariableName))
+ if (varName.equals(strippedVariableName)) {
return null; // no "silly suggestions"
- else
- return varName;
+ }
+ return varName;
}
// ---------------- Helper methods
@@ -519,25 +519,25 @@ public class RenamingNameSuggestor {
}
private String getLowerCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toLowerCase(name.charAt(0)) + name.substring(1);
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private String getUpperCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private String getFirstUpperRestLowerCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toUpperCase(name.charAt(0))
+ name.substring(1).toLowerCase();
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private boolean isInterfaceName(String typeName) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java
index d8a2c5448..d9bb91fbc 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.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,38 +44,41 @@ import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.MultiTextEdit;
-
-
class DeleteChangeCreator {
private DeleteChangeCreator() {
- //private
+ // private
}
- static Change createDeleteChange(TextChangeManager manager, IResource[] resources, IModelElement[] modelElements, String changeName) throws CoreException {
- final DynamicValidationStateChange result= new DynamicValidationStateChange(changeName) {
+ static Change createDeleteChange(TextChangeManager manager,
+ IResource[] resources, IModelElement[] modelElements,
+ String changeName) throws CoreException {
+ final DynamicValidationStateChange result = new DynamicValidationStateChange(
+ changeName) {
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
super.perform(pm);
return null;
}
};
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
- if (! ReorgUtils.isInsideSourceModule(element))
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
+ if (!ReorgUtils.isInsideSourceModule(element))
result.add(createDeleteChange(element));
}
- for (int i= 0; i < resources.length; i++) {
+ for (int i = 0; i < resources.length; i++) {
result.add(createDeleteChange(resources[i]));
}
- Map grouped= ReorgUtils.groupBySourceModule(getElementsSmallerThanCu(modelElements));
- if (grouped.size() != 0 ){
+ Map grouped = ReorgUtils
+ .groupBySourceModule(getElementsSmallerThanCu(modelElements));
+ if (grouped.size() != 0) {
Assert.isNotNull(manager);
- for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) {
- ISourceModule cu= (ISourceModule) iter.next();
- Change change = createDeleteChange(cu, (List)grouped.get(cu), manager);
- if( change != null ) {
+ for (Iterator iter = grouped.keySet().iterator(); iter.hasNext();) {
+ ISourceModule cu = (ISourceModule) iter.next();
+ Change change = createDeleteChange(cu, (List) grouped.get(cu),
+ manager);
+ if (change != null) {
result.add(change);
}
}
@@ -85,13 +88,15 @@ class DeleteChangeCreator {
}
private static Change createDeleteChange(IResource resource) {
- Assert.isTrue(! (resource instanceof IWorkspaceRoot));//cannot be done
- Assert.isTrue(! (resource instanceof IProject)); //project deletion is handled by the workbench
+ Assert.isTrue(!(resource instanceof IWorkspaceRoot));// cannot be done
+ Assert.isTrue(!(resource instanceof IProject)); // project deletion is
+ // handled by the
+ // workbench
if (resource instanceof IFile)
- return new DeleteFileChange((IFile)resource, true);
+ return new DeleteFileChange((IFile) resource, true);
if (resource instanceof IFolder)
- return new DeleteFolderChange((IFolder)resource, true);
- Assert.isTrue(false);//there're no more kinds
+ return new DeleteFolderChange((IFolder) resource, true);
+ Assert.isTrue(false);// there're no more kinds
return null;
}
@@ -103,41 +108,43 @@ class DeleteChangeCreator {
throws CoreException {
// SourceModule cuNode= RefactoringASTParser.parseWithASTProvider(cu, false, null);
// SourceModuleRewrite rewriter= new SourceModuleRewrite(cu, cuNode);
- Assert.isNotNull(cu);
- Assert.isNotNull(modelElements);
- Assert.isNotNull(manager);
- TextFileChange textFileChange = null;
- if (cu != null && cu.getResource() instanceof IFile) {
- textFileChange = new TextFileChange(cu.getElementName(), (IFile)cu.getResource());
- MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
- textFileChange.setEdit(fileChangeRootEdit);
+ Assert.isNotNull(cu);
+ Assert.isNotNull(modelElements);
+ Assert.isNotNull(manager);
+ TextFileChange textFileChange = null;
+ if (cu != null && cu.getResource() instanceof IFile) {
+ textFileChange = new TextFileChange(cu.getElementName(),
+ (IFile) cu.getResource());
+ MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
+ textFileChange.setEdit(fileChangeRootEdit);
- manager.manage(cu, textFileChange);
+ manager.manage(cu, textFileChange);
IModelElement[] elements = modelElements
.toArray(new IModelElement[modelElements.size()]);
- for (int cnt = 0, max = elements.length; cnt < max; cnt++) {
- ISourceRange sourceRange = null;
- if (elements[cnt] instanceof IMember) {
- IMember type = (IMember)elements[cnt];
- sourceRange = type.getSourceRange();
- }
- if (sourceRange != null) {
- DeleteEdit edit = new DeleteEdit(sourceRange.getOffset(), sourceRange.getLength());
-
- fileChangeRootEdit.addChild(edit);
- if (cu.isWorkingCopy()) {
- textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- }
-
- }
- }
- }
-
- // ASTNodeDeleteUtil.markAsDeleted(elements, rewriter, null);
+ for (int cnt = 0, max = elements.length; cnt < max; cnt++) {
+ ISourceRange sourceRange = null;
+ if (elements[cnt] instanceof IMember) {
+ IMember type = (IMember) elements[cnt];
+ sourceRange = type.getSourceRange();
+ }
+ if (sourceRange != null) {
+ DeleteEdit edit = new DeleteEdit(sourceRange.getOffset(),
+ sourceRange.getLength());
+
+ fileChangeRootEdit.addChild(edit);
+ if (cu.isWorkingCopy()) {
+ textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
+
+ }
+ }
+ }
+
+ // ASTNodeDeleteUtil.markAsDeleted(elements, rewriter, null);
// return addTextEditFromRewrite(manager, cu, rewriter.getASTRewrite());
- return textFileChange;
+ return textFileChange;
}
// private static TextChange addTextEditFromRewrite(TextChangeManager manager, ISourceModule cu, ASTRewrite rewrite) throws CoreException {
@@ -158,11 +165,12 @@ class DeleteChangeCreator {
// }
// }
- //List<IModelElement>
- private static List getElementsSmallerThanCu(IModelElement[] modelElements){
- List result= new ArrayList();
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
+ // List<IModelElement>
+ private static List getElementsSmallerThanCu(
+ IModelElement[] modelElements) {
+ List result = new ArrayList();
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
if (ReorgUtils.isInsideSourceModule(element))
result.add(element);
}
@@ -170,71 +178,79 @@ class DeleteChangeCreator {
}
private static Change createDeleteChange(IModelElement modelElement) {
- Assert.isTrue(! ReorgUtils.isInsideSourceModule(modelElement));
+ Assert.isTrue(!ReorgUtils.isInsideSourceModule(modelElement));
- switch(modelElement.getElementType()){
- case IModelElement.PROJECT_FRAGMENT:
- return createProjectFragmentDeleteChange((IProjectFragment)modelElement);
+ switch (modelElement.getElementType()) {
+ case IModelElement.PROJECT_FRAGMENT:
+ return createProjectFragmentDeleteChange(
+ (IProjectFragment) modelElement);
- case IModelElement.SCRIPT_FOLDER:
- return createSourceManipulationDeleteChange((IScriptFolder)modelElement);
+ case IModelElement.SCRIPT_FOLDER:
+ return createSourceManipulationDeleteChange(
+ (IScriptFolder) modelElement);
- case IModelElement.SOURCE_MODULE:
- return createSourceManipulationDeleteChange((ISourceModule)modelElement);
+ case IModelElement.SOURCE_MODULE:
+ return createSourceManipulationDeleteChange(
+ (ISourceModule) modelElement);
- case IModelElement.SCRIPT_MODEL: //cannot be done
- Assert.isTrue(false);
- return null;
+ case IModelElement.SCRIPT_MODEL: // cannot be done
+ Assert.isTrue(false);
+ return null;
- case IModelElement.SCRIPT_PROJECT: //handled differently
- Assert.isTrue(false);
- return null;
+ case IModelElement.SCRIPT_PROJECT: // handled differently
+ Assert.isTrue(false);
+ return null;
- case IModelElement.TYPE:
- case IModelElement.FIELD:
- case IModelElement.METHOD:
+ case IModelElement.TYPE:
+ case IModelElement.FIELD:
+ case IModelElement.METHOD:
// case IModelElement.INITIALIZER:
// case IModelElement.PACKAGE_DECLARATION:
// case IModelElement.IMPORT_CONTAINER:
// case IModelElement.IMPORT_DECLARATION:
// Assert.isTrue(false);//not done here
- default:
- Assert.isTrue(false);//there's no more kinds
- return new NullChange();
+ default:
+ Assert.isTrue(false);// there's no more kinds
+ return new NullChange();
}
}
- private static Change createSourceManipulationDeleteChange(ISourceManipulation element) {
- //XXX workaround for bug 31384, in case of linked ISourceManipulation delete the resource
- if (element instanceof ISourceModule || element instanceof IScriptFolder){
+ private static Change createSourceManipulationDeleteChange(
+ ISourceManipulation element) {
+ // XXX workaround for bug 31384, in case of linked ISourceManipulation
+ // delete the resource
+ if (element instanceof ISourceModule
+ || element instanceof IScriptFolder) {
IResource resource;
if (element instanceof ISourceModule)
- resource= ReorgUtils.getResource((ISourceModule)element);
+ resource = ReorgUtils.getResource((ISourceModule) element);
else
- resource= ((IScriptFolder)element).getResource();
+ resource = ((IScriptFolder) element).getResource();
if (resource != null && resource.isLinked())
return createDeleteChange(resource);
}
return new DeleteSourceManipulationChange(element, true);
}
- private static Change createProjectFragmentDeleteChange(IProjectFragment root) {
- IResource resource= root.getResource();
- if (resource != null && resource.isLinked()){
- //XXX using this code is a workaround for jcore bug 31998
- //jcore cannot handle linked stuff
- //normally, we should always create DeleteProjectFragmentChange
- CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);
+ private static Change createProjectFragmentDeleteChange(
+ IProjectFragment root) {
+ IResource resource = root.getResource();
+ if (resource != null && resource.isLinked()) {
+ // XXX using this code is a workaround for jcore bug 31998
+ // jcore cannot handle linked stuff
+ // normally, we should always create DeleteProjectFragmentChange
+ CompositeChange composite = new DynamicValidationStateChange(
+ RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);
composite.add(new DeleteFromBuildpathChange(root));
- Assert.isTrue(! Checks.isBuildpathDelete(root));//checked in preconditions
+ Assert.isTrue(!Checks.isBuildpathDelete(root));// checked in
+ // preconditions
composite.add(createDeleteChange(resource));
return composite;
- } else {
- Assert.isTrue(! root.isExternal());
- // TODO remove the query argument
- return new DeleteProjectFragmentChange(root, true, null);
}
+ Assert.isTrue(!root.isExternal());
+ // TODO remove the query argument
+ return new DeleteProjectFragmentChange(root, true, null);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java
index ac322bf7f..63607b7a8 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.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
@@ -224,9 +224,8 @@ class OverwriteHelper {
IScriptFolder destination = (IScriptFolder) fDestination;
return !destination.equals(cu.getParent()) && destination
.getSourceModule(cu.getElementName()).exists();
- } else {
- return canOverwrite(ReorgUtils.getResource(cu));
}
+ return canOverwrite(ReorgUtils.getResource(cu));
}
private static boolean overwrite(IResource resource,
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java
index 9e7ed5444..e24a44cc6 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.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
@@ -41,10 +41,10 @@ public class ParentChecker {
Assert.isNotNull(commonResourceParent);
IModelElement convertedToScript = DLTKCore
.create(commonResourceParent);
- if (convertedToScript != null && convertedToScript.exists())
+ if (convertedToScript != null && convertedToScript.exists()) {
return convertedToScript;
- else
- return commonResourceParent;
+ }
+ return commonResourceParent;
}
if (fResources.length == 0)
return getCommonScriptElementParent();
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 2238ada58..5177ad564 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
@@ -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
@@ -124,12 +124,12 @@ public class ReorgPolicyFactory {
if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
modelElements, IModelElement.SCRIPT_FOLDER))
return NO;
- if (copy)
+ if (copy) {
return new CopyPackagesPolicy(
ArrayTypeConverter.toPackageArray(modelElements));
- else
- return new MovePackagesPolicy(
- ArrayTypeConverter.toPackageArray(modelElements));
+ }
+ return new MovePackagesPolicy(
+ ArrayTypeConverter.toPackageArray(modelElements));
}
if (ReorgUtils.hasElementsOfType(modelElements,
@@ -137,12 +137,12 @@ public class ReorgPolicyFactory {
if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
modelElements, IModelElement.PROJECT_FRAGMENT))
return NO;
- if (copy)
+ if (copy) {
return new CopyProjectFragmentsPolicy(ArrayTypeConverter
.toProjectFragmentArray(modelElements));
- else
- return new MoveProjectFragmentsPolicy(ArrayTypeConverter
- .toProjectFragmentArray(modelElements));
+ }
+ return new MoveProjectFragmentsPolicy(
+ ArrayTypeConverter.toProjectFragmentArray(modelElements));
}
if (ReorgUtils.hasElementsOfType(resources,
@@ -155,16 +155,16 @@ public class ReorgPolicyFactory {
if (ReorgUtils.hasElementsNotOfType(resources,
IResource.FILE | IResource.FOLDER))
return NO;
- if (copy)
+ if (copy) {
return new CopyFilesFoldersAndCusPolicy(
ReorgUtils.getFiles(resources),
ReorgUtils.getFolders(resources),
ArrayTypeConverter.toCuArray(modelElements));
- else
- return new MoveFilesFoldersAndCusPolicy(
- ReorgUtils.getFiles(resources),
- ReorgUtils.getFolders(resources),
- ArrayTypeConverter.toCuArray(modelElements));
+ }
+ return new MoveFilesFoldersAndCusPolicy(
+ ReorgUtils.getFiles(resources),
+ ReorgUtils.getFolders(resources),
+ ArrayTypeConverter.toCuArray(modelElements));
}
if (hasElementsSmallerThanCuOrClassFile(modelElements)) {
@@ -173,15 +173,14 @@ public class ReorgPolicyFactory {
Assert.isTrue(!ReorgUtils.hasElementsOfType(modelElements,
IModelElement.SOURCE_MODULE));
Assert.isTrue(!hasElementsLargerThanCuOrClassFile(modelElements));
- if (copy)
+ if (copy) {
return new CopySubCuElementsPolicy(modelElements);
- else {
- if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
- }
- // return new MoveSubCuElementsPolicy(modelElements);
}
+ if (DLTKCore.DEBUG) {
+ System.err.println(
+ "TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
+ }
+ // return new MoveSubCuElementsPolicy(modelElements);
}
return NO;
}
@@ -308,9 +307,8 @@ public class ReorgPolicyFactory {
if (modifications != null) {
return modifications.loadParticipants(status, processor,
natures, shared);
- } else {
- return new RefactoringParticipant[0];
}
+ return new RefactoringParticipant[0];
}
@Override
@@ -947,10 +945,10 @@ public class ReorgPolicyFactory {
private IScriptProject getDestinationAsScriptProject(
IModelElement modelElementDestination) {
- if (modelElementDestination == null)
+ if (modelElementDestination == null) {
return null;
- else
- return modelElementDestination.getScriptProject();
+ }
+ return modelElementDestination.getScriptProject();
}
protected IProjectFragment[] getProjectFragments() {
@@ -1490,17 +1488,15 @@ public class ReorgPolicyFactory {
newName);
}
return new CopyScriptFolderChange(pack, destination, nameQuery);
- } else {
- if (destination.getResource() instanceof IContainer) {
- IContainer dest = (IContainer) destination.getResource();
- IResource res = pack.getResource();
- INewNameQuery nameQuery = copyQueries
- .createNewResourceNameQuery(res, newName);
- return new CopyResourceChange(res, dest, nameQuery);
- } else {
- return new NullChange();
- }
}
+ if (destination.getResource() instanceof IContainer) {
+ IContainer dest = (IContainer) destination.getResource();
+ IResource res = pack.getResource();
+ INewNameQuery nameQuery = copyQueries
+ .createNewResourceNameQuery(res, newName);
+ return new CopyResourceChange(res, dest, nameQuery);
+ }
+ return new NullChange();
}
}
@@ -2038,9 +2034,8 @@ public class ReorgPolicyFactory {
public Change createChange(IProgressMonitor pm) throws ModelException {
if (!fUpdateReferences) {
return createSimpleMoveChange(pm);
- } else {
- return createReferenceUpdatingMoveChange(pm);
}
+ return createReferenceUpdatingMoveChange(pm);
}
@Override
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 69df01232..c80b88d9b 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
@@ -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
@@ -128,9 +128,8 @@ public class ReorgUtils {
case IModelElement.SOURCE_MODULE:
if (element instanceof ExternalSourceModule) {
return RefactoringCoreMessages.ReorgUtils_21;
- } else {
- return RefactoringCoreMessages.ReorgUtils_4;
}
+ return RefactoringCoreMessages.ReorgUtils_4;
case IModelElement.FIELD:
return RefactoringCoreMessages.ReorgUtils_5;
// case IModelElement.IMPORT_CONTAINER:
@@ -140,17 +139,17 @@ public class ReorgUtils {
case IModelElement.SCRIPT_PROJECT:
return RefactoringCoreMessages.ReorgUtils_9;
case IModelElement.METHOD:
- if (((IMethod) element).isConstructor())
+ if (((IMethod) element).isConstructor()) {
return RefactoringCoreMessages.ReorgUtils_10;
- else
- return RefactoringCoreMessages.ReorgUtils_11;
- // case IModelElement.PACKAGE_DECLARATION:
- // return RefactoringCoreMessages.ReorgUtils_12;
+ }
+ return RefactoringCoreMessages.ReorgUtils_11;
+ // case IModelElement.PACKAGE_DECLARATION:
+ // return RefactoringCoreMessages.ReorgUtils_12;
case IModelElement.SCRIPT_FOLDER:
- if (ModelElementUtil.isDefaultPackage(element))
+ if (ModelElementUtil.isDefaultPackage(element)) {
return RefactoringCoreMessages.ReorgUtils_13;
- else
- return RefactoringCoreMessages.ReorgUtils_14;
+ }
+ return RefactoringCoreMessages.ReorgUtils_14;
case IModelElement.PROJECT_FRAGMENT:
if (isSourceFolder(element))
return RefactoringCoreMessages.ReorgUtils_15;
@@ -173,9 +172,8 @@ public class ReorgUtils {
if (element instanceof ExternalSourceModule) {
return new String[] { ((ExternalSourceModule) element)
.getFullPath().toString() };
- } else {
- return new String[] { element.getElementName() };
}
+ return new String[] { element.getElementName() };
case IModelElement.FIELD:
return new String[] { element.getElementName() };
// case IModelElement.IMPORT_CONTAINER:
@@ -223,10 +221,10 @@ public class ReorgUtils {
}
public static IResource getResource(IModelElement element) {
- if (element instanceof ISourceModule)
+ if (element instanceof ISourceModule) {
return ((ISourceModule) element).getPrimary().getResource();
- else
- return element.getResource();
+ }
+ return element.getResource();
}
public static IResource[] getResources(IModelElement[] elements) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java
index 2923086cf..1475ebe3a 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.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
@@ -116,7 +116,7 @@ public class ModelElementUtil {
/**
* @param pack
- * a package fragment
+ * a package fragment
* @return an array containing the given package and all subpackages
* @throws ModelException
*/
@@ -142,7 +142,7 @@ public class ModelElementUtil {
/**
* @param pack
- * the package fragment; may not be null
+ * the package fragment; may not be null
* @return the parent package fragment, or null if the given package
* fragment is the default package or a top level package
*/
@@ -155,10 +155,10 @@ public class ModelElementUtil {
final IProjectFragment root = (IProjectFragment) pack.getParent();
final String newPackageName = pack.getElementName().substring(0, index);
final IScriptFolder parent = root.getScriptFolder(newPackageName);
- if (parent.exists())
+ if (parent.exists()) {
return parent;
- else
- return null;
+ }
+ return null;
}
public static IMember[] sortByOffset(IMember[] members) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java
index 832f699c4..b772bac28 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.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
@@ -61,12 +61,10 @@ public class OpenMethodHistory extends History {
IDLTKUILanguageToolkit toolkit) {
if (sToolkitHistory.containsKey(toolkit)) {
return (OpenMethodHistory) sToolkitHistory.get(toolkit);
- } else {
- OpenMethodHistory his = new OpenMethodHistory(toolkit);
- sToolkitHistory.put(toolkit, his);
- return his;
}
-
+ OpenMethodHistory his = new OpenMethodHistory(toolkit);
+ sToolkitHistory.put(toolkit, his);
+ return his;
}
private class MethodHistoryDeltaListener
@@ -82,7 +80,7 @@ public class OpenMethodHistory extends History {
* Computes whether the history needs a consistency check or not.
*
* @param delta
- * the Java element delta
+ * the Java element delta
*
* @return <code>true</code> if consistency must be checked
* <code>false</code> otherwise.
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java
index 3a0ceab68..417bb257a 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.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
@@ -62,11 +62,10 @@ public class OpenTypeHistory extends History implements IShutdownListener {
IDLTKUILanguageToolkit toolkit) {
if (sToolkitHistory.containsKey(toolkit)) {
return sToolkitHistory.get(toolkit);
- } else {
- OpenTypeHistory his = new OpenTypeHistory(toolkit);
- sToolkitHistory.put(toolkit, his);
- return his;
}
+ OpenTypeHistory his = new OpenTypeHistory(toolkit);
+ sToolkitHistory.put(toolkit, his);
+ return his;
}
private class TypeHistoryDeltaListener implements IElementChangedListener {
@@ -81,7 +80,7 @@ public class OpenTypeHistory extends History implements IShutdownListener {
* Computes whether the history needs a consistency check or not.
*
* @param delta
- * the Java element delta
+ * the Java element delta
*
* @return <code>true</code> if consistency must be checked
* <code>false</code> otherwise.
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
index 836e5dcff..d6bcb1cb9 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
@@ -1,15 +1,13 @@
/*******************************************************************************
- * 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.corext.documentation;
-
import java.io.IOException;
import java.io.Reader;
@@ -20,22 +18,21 @@ public abstract class SingleCharReader extends Reader {
@Override
public int read(char cbuf[], int off, int len) throws IOException {
- int end= off + len;
- for (int i= off; i < end; i++) {
- int ch= read();
+ int end = off + len;
+ for (int i = off; i < end; i++) {
+ int ch = read();
if (ch == -1) {
if (i == off) {
return -1;
- } else {
- return i - off;
}
+ return i - off;
}
- cbuf[i]= (char)ch;
+ cbuf[i] = (char) ch;
}
return len;
}
- @Override
+ @Override
public boolean ready() throws IOException {
return true;
}
@@ -44,10 +41,10 @@ public abstract class SingleCharReader extends Reader {
* Gets the content as a String
*/
public String getString() throws IOException {
- StringBuffer buf= new StringBuffer();
+ StringBuffer buf = new StringBuffer();
int ch;
- while ((ch= read()) != -1) {
- buf.append((char)ch);
+ while ((ch = read()) != -1) {
+ buf.append((char) ch);
}
return buf.toString();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java
index 750d15349..bbee0e42d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.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
@@ -75,7 +75,7 @@ public class BuildpathModifier {
* <code>IBuildpathEntry</code>, but <code>BPListElement</code>
*
* @param newEntries
- * list of <code>BPListElement</code>
+ * list of <code>BPListElement</code>
*/
public void buildpathEntryChanged(List newEntries);
}
@@ -94,11 +94,11 @@ public class BuildpathModifier {
* Create a linked source folder.
*
* @param query
- * a query to create a linked source folder
+ * a query to create a linked source folder
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list containing a <code>IProjectFragment</code> representing
* the linked source folder
* @throws CoreException
@@ -128,15 +128,15 @@ public class BuildpathModifier {
* <code>FolderCreationQuery.getCreatedFolder()</code>.
*
* @param folderQuery
- * query to create the new folder
+ * query to create the new folder
* @param outputQuery
- * query to get information about whether the project should be
- * removed as source folder and update build folder to
- * <code>outputLocation</code>
+ * query to get information about whether the project
+ * should be removed as source folder and update
+ * build folder to <code>outputLocation</code>
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list containing the created object (either of type
* <code>IResource</code> of <code>IModelElement</code>, or an empty
* list if no folder was created (e.g. the operation was cancelled).
@@ -158,12 +158,11 @@ public class BuildpathModifier {
if (root.size() == 0)
folder.delete(false, null);
return root;
- } else {
- List entries = getExistingEntries(project);
- exclude(folder.getFullPath(), entries, new ArrayList(),
- project, monitor);
- updateBuildpath(entries, project, null);
}
+ List entries = getExistingEntries(project);
+ exclude(folder.getFullPath(), entries, new ArrayList(), project,
+ monitor);
+ updateBuildpath(entries, project, null);
return folderList;
}
}
@@ -174,17 +173,17 @@ public class BuildpathModifier {
* Add a list of elements to the build path.
*
* @param elements
- * a list of elements to be added to the build path. An element
- * must either be of type <code>IFolder</code>,
- * <code>IModelElement</code> or <code>IFile</code> (only allowed
- * if the file is a .zip file!).
+ * a list of elements to be added to the build path. An
+ * element must either be of type <code>IFolder</code>,
+ * <code>IModelElement</code> or <code>IFile</code>
+ * (only allowed if the file is a .zip file!).
* @param project
- * the script project
+ * the script project
* @param query
- * for information about whether the project should be removed as
- * source folder and update build folder
+ * for information about whether the project should be
+ * removed as source folder and update build folder
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns a list of elements of type <code>IProjectFragment</code>
* or <code>IScriptProject</code> that have been added to the build
* path or an empty list if the operation was aborted
@@ -252,12 +251,11 @@ public class BuildpathModifier {
}
return result;
- } else {
- StatusInfo rootStatus = new StatusInfo();
- rootStatus.setError(
- NewWizardMessages.BuildpathModifier_Error_NoNatures);
- throw new CoreException(rootStatus);
}
+ StatusInfo rootStatus = new StatusInfo();
+ rootStatus.setError(
+ NewWizardMessages.BuildpathModifier_Error_NoNatures);
+ throw new CoreException(rootStatus);
} finally {
monitor.done();
}
@@ -268,12 +266,12 @@ public class BuildpathModifier {
* query to find out which entries need to be added.
*
* @param query
- * the query to get the information which entries need to be
- * added
+ * the query to get the information which entries need to
+ * be added
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>IProjectFragment</code>s representing the added
* archives or an empty list if no element was added.
* @throws CoreException
@@ -330,12 +328,12 @@ public class BuildpathModifier {
* which entries need to be added.
*
* @param query
- * the query to get the information which entries need to be
- * added
+ * the query to get the information which entries need to
+ * be added
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>BuildpathContainer</code>s representing the added
* archives or an empty list if no element was added.
* @throws CoreException
@@ -426,16 +424,18 @@ public class BuildpathModifier {
* Remove a list of elements to the build path.
*
* @param query
- * query to remove unused linked folders from the project
+ * query to remove unused linked folders from the
+ * project
* @param elements
- * a list of elements to be removed from the build path. An
- * element must either be of type <code>IScriptProject</code>,
- * <code>IProjectFragment</code> or
- * <code>BuildPathContainer</code>
+ * a list of elements to be removed from the build path.
+ * An element must either be of type
+ * <code>IScriptProject</code>,
+ * <code>IProjectFragment</code> or
+ * <code>BuildPathContainer</code>
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns a list of elements of type <code>IFile</code> (in case of
* removed archives) or <code>IFolder</code> that have been removed
* from the build path
@@ -538,12 +538,13 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param elements
- * a list of elements to be included. The elements must be either
- * of type <code>IResource</code> or <code>IModelElement</code>.
+ * a list of elements to be included. The elements must
+ * be either of type <code>IResource</code> or
+ * <code>IModelElement</code>.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>IModelElement</code>s corresponding to the
* included ones.
* @throws ModelException
@@ -599,11 +600,11 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param scriptElements
- * list of script elements to be excluded
+ * list of script elements to be excluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return list of objects representing the excluded elements
* @throws ModelException
*/
@@ -649,11 +650,12 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param scriptElements
- * a list of <code>IModelElements</code> to be unincluded
+ * a list of <code>IModelElements</code> to be
+ * unincluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of elements representing unexcluded elements
* @throws ModelException
*
@@ -699,11 +701,11 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param elements
- * list of <code>IResource</code>s to be unexcluded
+ * list of <code>IResource</code>s to be unexcluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return an object representing the unexcluded element
* @throws ModelException
*
@@ -745,13 +747,13 @@ public class BuildpathModifier {
* passed <code>IInclusionExclusionQuery</code>.
*
* @param element
- * the script element to edit the filters on. Must be either of
- * type <code>IScriptProject</code> or
- * <code>IProjectFragment</code>.
+ * the script element to edit the filters on. Must be
+ * either of type <code>IScriptProject</code> or
+ * <code>IProjectFragment</code>.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the edited script element or <code>null</code> if the
* operation was cancelled
* @throws ModelException
@@ -800,9 +802,9 @@ public class BuildpathModifier {
* given attribute is reset to the default output location.</li>
*
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of elements representing the elements on which 'reset' was
* called. They can either be of type <code>BPListElement</code>,
* <code>IScriptProject</code> or <code>IProjectFragment</code>
@@ -852,7 +854,7 @@ public class BuildpathModifier {
* a list of <code>BPListElement</code>s.
*
* @param project
- * the script project to get it's build path entries from
+ * the script project to get it's build path entries from
* @return a list of <code>BPListElement</code>s corresponding to the build
* path entries of the project
* @throws ModelException
@@ -875,10 +877,10 @@ public class BuildpathModifier {
* <code>BPListElement</code> and returned.
*
* @param elements
- * a list of <code>BPListElements</code>
+ * a list of <code>BPListElements</code>
* @param root
- * the root to find the <code>BuildpathEntry</code> for
- * represented by a <code>BPListElement</code>
+ * the root to find the <code>BuildpathEntry</code> for
+ * represented by a <code>BPListElement</code>
* @return the <code>BPListElement</code> found in the list (matching by
* using the path) or the roots own <code>IBuildpathEntry</code>
* converted to a <code>BPListElement</code>.
@@ -905,7 +907,7 @@ public class BuildpathModifier {
* no fragment root could be created.
*
* @param resource
- * the resource to be converted
+ * the resource to be converted
* @return the <code>resource<code> as
* <code>IScriptFolder</code>,or <code>null</code> if failed to convert
*/
@@ -921,11 +923,11 @@ public class BuildpathModifier {
* with the resource's parent.
*
* @param resource
- * the resource to get the fragment root from
+ * the resource to get the fragment root from
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return resolved fragment root
* @throws ModelException
*/
@@ -963,9 +965,9 @@ public class BuildpathModifier {
* build path entries on the project
*
* @param path
- * the path to find a build path entry for
+ * the path to find a build path entry for
* @param project
- * the script project
+ * the script project
* @return the <code>IBuildpathEntry</code> corresponding to the
* <code>path</code> or <code>null</code> if there is no such entry
* @throws ModelException
@@ -987,7 +989,7 @@ public class BuildpathModifier {
* folder or not
*
* @param attrib
- * the attribute to be checked
+ * the attribute to be checked
* @return <code>true</code> if is the default output folder,
* <code>false</code> otherwise.
*/
@@ -1001,11 +1003,11 @@ public class BuildpathModifier {
* inclusion filter of it's parent source folder.
*
* @param selection
- * the current script element
+ * the current script element
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return <code>true</code> if the current selection is included,
* <code>false</code> otherwise.
* @throws ModelException
@@ -1038,9 +1040,9 @@ public class BuildpathModifier {
* Find out whether the <code>IResource</code> excluded or not.
*
* @param resource
- * the resource to be checked
+ * the resource to be checked
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if the resource is excluded, <code>
* false</code> otherwise
* @throws ModelException
@@ -1061,9 +1063,10 @@ public class BuildpathModifier {
* Find out whether one of the <code>IResource</code>'s parents is excluded.
*
* @param resource
- * check the resources parents whether they are excluded or not
+ * check the resources parents whether they are excluded
+ * or not
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if there is an excluded parent,
* <code>false</code> otherwise
* @throws ModelException
@@ -1126,7 +1129,7 @@ public class BuildpathModifier {
* Check whether the <code>IScriptProject</code> is a source folder
*
* @param project
- * the project to test
+ * the project to test
* @return <code>true</code> if <code>project</code> is a source folder
* <code>false</code> otherwise.
*/
@@ -1141,7 +1144,7 @@ public class BuildpathModifier {
* default fragment.
*
* @param fragment
- * the package fragment to be checked
+ * the package fragment to be checked
* @return <code>true</code> if is the default package fragment,
* <code>false</code> otherwise.
*/
@@ -1184,7 +1187,7 @@ public class BuildpathModifier {
* both set (that means they are not empty).
*
* @param root
- * the fragment root to be inspected
+ * the fragment root to be inspected
* @return <code>true</code> inclusion or exclusion filter set,
* <code>false</code> otherwise.
*/
@@ -1206,11 +1209,11 @@ public class BuildpathModifier {
* Add a resource to the build path.
*
* @param resource
- * the resource to be added to the build path
+ * the resource to be added to the build path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the new element of type <code>IProjectFragment</code>
* that has been added to the build path
* @throws CoreException
@@ -1241,9 +1244,9 @@ public class BuildpathModifier {
* Check whether the provided file is an archive (.zip).
*
* @param file
- * the file to be checked
+ * the file to be checked
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if the file is an archive, <code>false</code>
* otherwise
* @throws ModelException
@@ -1262,11 +1265,11 @@ public class BuildpathModifier {
* Add a script element to the build path.
*
* @param scriptElement
- * element to be added to the build path
+ * element to be added to the build path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the new element of type <code>IProjectFragment</code>
* that has been added to the build path
* @throws CoreException
@@ -1295,12 +1298,13 @@ public class BuildpathModifier {
* Remove the script project from the build path
*
* @param project
- * the project to be removed
+ * the project to be removed
* @param existingEntries
- * a list of existing <code>BPListElement</code>. This list will
- * be traversed and the entry for the project will be removed.
+ * a list of existing <code>BPListElement</code>.
+ * This list will be traversed and the entry for
+ * the project will be removed.
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the script project
* @throws CoreException
*/
@@ -1318,16 +1322,17 @@ public class BuildpathModifier {
* Remove a given <code>IProjectFragment</code> from the build path.
*
* @param root
- * the <code>IProjectFragment</code> to be removed from the build
- * path
+ * the <code>IProjectFragment</code> to be
+ * removed from the build path
* @param existingEntries
- * a list of <code>BPListElements</code> representing the build
- * path entries of the project. The entry for the root will be
- * looked up and removed from the list.
+ * a list of <code>BPListElements</code>
+ * representing the build path entries of the
+ * project. The entry for the root will be looked
+ * up and removed from the list.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the <code>IResource</code> that has been removed from the
* build path; is of type <code>IFile</code> if the root was an
* archive, otherwise <code>IFolder</code> or <code>null<code> for
@@ -1358,12 +1363,13 @@ public class BuildpathModifier {
* <code>existingEntries</code>
*
* @param path
- * the path to remove
+ * the path to remove
* @param project
- * the script project
+ * the script project
* @param existingEntries
- * a list of <code>BPListElement</code> representing the build
- * path entries of the project.
+ * a list of <code>BPListElement</code>
+ * representing the build path entries of the
+ * project.
* @return returns a <code>List</code> of <code>BPListElement</code> of
* modified elements, not null.
*/
@@ -1428,14 +1434,14 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param resource
- * the element to be included
+ * the element to be included
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the resource's root
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the resource's root
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*
* @throws ModelException
*
@@ -1477,15 +1483,15 @@ public class BuildpathModifier {
* path.
*
* @param name
- * the name of the element to be excluded
+ * the name of the element to be excluded
* @param fullPath
- * the absolute path of the element
+ * the absolute path of the element
* @param entry
- * the build path entry to be modified
+ * the build path entry to be modified
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a <code>IResource</code> corresponding to the excluded element
* @throws ModelException
*/
@@ -1533,15 +1539,15 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param path
- * absolute path of an object to be excluded
+ * absolute path of an object to be excluded
* @param existingEntries
- * a list of existing build path entries
+ * a list of existing build path entries
* @param newEntries
- * a list of new build path entries
+ * a list of new build path entries
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*/
public static void exclude(IPath path, List existingEntries,
List newEntries, IScriptProject project, IProgressMonitor monitor)
@@ -1585,14 +1591,15 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param scriptElement
- * the script element to be excluded
+ * the script element to be excluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the script element's root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the script
+ * element's root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*
* @return the resulting <code>IResource<code>
* @throws ModelException
@@ -1621,14 +1628,14 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param scriptElement
- * the script element to be unincluded
+ * the script element to be unincluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*
* @see #include(List, IScriptProject, IProgressMonitor)
@@ -1664,14 +1671,14 @@ public class BuildpathModifier {
* parent fragment is allowed.
*
* @param resource
- * the resource to be unexcluded
+ * the resource to be unexcluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the resource's root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the resource's root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*
* @see #exclude(List, IScriptProject, IProgressMonitor)
@@ -1702,13 +1709,14 @@ public class BuildpathModifier {
* <code>IModelElement</code>
*
* @param element
- * element to reset it's filters
+ * element to reset it's filters
* @param entry
- * the <code>BPListElement</code> to reset its filters for
+ * the <code>BPListElement</code> to reset its filters
+ * for
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*/
private void resetFilters(IModelElement element, BPListElement entry,
@@ -1740,10 +1748,10 @@ public class BuildpathModifier {
* <code>BPListElement</code> is returned.
*
* @param elements
- * a list of <code>BPListElements</code>
+ * a list of <code>BPListElements</code>
* @param cpElement
- * the <code>BPListElement</code> to find the corresponding entry
- * in the list
+ * the <code>BPListElement</code> to find the
+ * corresponding entry in the list
* @return the <code>BPListElement</code> found in the list (matching by
* using the path) or the second <code>BPListElement</code>
* parameter itself if there is no match.
@@ -1764,9 +1772,9 @@ public class BuildpathModifier {
* For a given path, find the corresponding element in the list.
*
* @param path
- * the path to found an entry for
+ * the path to found an entry for
* @param elements
- * a list of <code>BPListElement</code>s
+ * a list of <code>BPListElement</code>s
* @return the mathed <code>BPListElement</code> or <code>null</code> if no
* match could be found
*/
@@ -1788,14 +1796,15 @@ public class BuildpathModifier {
* excluding an object.
*
* @param newEntries
- * a list of <code>BPListElements</code> that should be used as
- * build path entries for the project.
+ * a list of <code>BPListElements</code> that should
+ * be used as build path entries for the project.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
- * in case that validation for the new entries fails
+ * in case that validation for the new entries
+ * fails
*/
private void updateBuildpath(List newEntries, IScriptProject project,
IProgressMonitor monitor) throws ModelException {
@@ -1841,12 +1850,13 @@ public class BuildpathModifier {
* in the project and return a list with corresponding elements.
*
* @param entries
- * a list of entries to find an appropriate representation for.
- * The list can contain elements of two types:
- * <li><code>IResource</code></li>
- * <li><code>IModelElement</code></li>
+ * a list of entries to find an appropriate
+ * representation for. The list can contain elements of
+ * two types:
+ * <li><code>IResource</code></li>
+ * <li><code>IModelElement</code></li>
* @param project
- * the script project
+ * the script project
* @return a list of elements corresponding to the passed entries.
*/
public static List getCorrespondingElements(List entries,
@@ -1877,9 +1887,9 @@ public class BuildpathModifier {
* either element of type <code>IFile</code> or <code>IFolder</code>.
*
* @param path
- * an absolute path to a resource
+ * an absolute path to a resource
* @param project
- * the script project
+ * the script project
* @return the resource matching to the path. Can be either an
* <code>IFile</code> or an <code>IFolder</code>.
*/
@@ -1891,11 +1901,11 @@ public class BuildpathModifier {
* Find out whether the provided path equals to one in the array.
*
* @param path
- * path to find an equivalent for
+ * path to find an equivalent for
* @param paths
- * set of paths to compare with
+ * set of paths to compare with
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return <code>true</code> if there is an occurrence, <code>
* false</code> otherwise
*/
@@ -1928,7 +1938,7 @@ public class BuildpathModifier {
* XXX this method does nothing, use {@link #completeName(IPath, String)}
*
* @param name
- * append '/' at the end if necessary
+ * append '/' at the end if necessary
* @return modified string
*/
@Deprecated
@@ -1951,9 +1961,10 @@ public class BuildpathModifier {
* {@link #completeName(IPath, String)}
*
* @param project
- * - the project containing the resource
+ * - the project containing the resource
* @param name
- * - name of the resource append '/' at the end if necessary
+ * - name of the resource append '/' at the end if
+ * necessary
* @return modified string
*/
@Deprecated
@@ -1973,9 +1984,10 @@ public class BuildpathModifier {
* Add a '/' at the end of the name if it maps to a folder.
*
* @param fullPath
- * - the project containing the resource
+ * - the project containing the resource
* @param name
- * - name of the resource append '/' at the end if necessary
+ * - name of the resource append '/' at the end if
+ * necessary
* @return modified string
*/
private static String completeName(IPath fullPath, String name) {
@@ -1998,11 +2010,11 @@ public class BuildpathModifier {
* Only the first occurrence will be removed.
*
* @param path
- * path to be removed
+ * path to be removed
* @param paths
- * array of path to apply the removal on
+ * array of path to apply the removal on
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return array which does not contain <code>path</code>
*/
private static IPath[] remove(IPath path, IPath[] paths,
@@ -2040,11 +2052,11 @@ public class BuildpathModifier {
* returned if they are also on the project's build path.
*
* @param path
- * absolute path
+ * absolute path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return an array of paths which belong to subfolders of <code>path</code>
* and which are on the build path
* @throws ModelException
@@ -2069,9 +2081,9 @@ public class BuildpathModifier {
* <code>rootPath<code>'s number of segments removed
*
* @param path
- * path to remove segments
+ * path to remove segments
* @param rootPath
- * provides the number of segments to be removed
+ * provides the number of segments to be removed
* @return a string corresponding to the mentioned action
*/
private static String getName(IPath path, IPath rootPath) {
@@ -2084,15 +2096,17 @@ public class BuildpathModifier {
* (therefore, there is no return list for this method).
*
* @param existingEntries
- * a list of existing buildpath entries
+ * a list of existing buildpath entries
* @param newEntries
- * a list of entries to be added to the existing ones
+ * a list of entries to be added to the existing
+ * ones
* @param project
- * the script project
+ * the script project
* @param monitor
- * a progress monitor, can be <code>null</code>
+ * a progress monitor, can be <code>null</code>
* @throws CoreException
- * in case that validation on one of the new entries fails
+ * in case that validation on one of the new
+ * entries fails
*/
public static void setNewEntry(List existingEntries, List newEntries,
IScriptProject project, IProgressMonitor monitor)
@@ -2116,7 +2130,7 @@ public class BuildpathModifier {
* <code>IBuildpathEntry</code>.
*
* @param list
- * the list to be converted
+ * the list to be converted
* @return an array containing build path entries corresponding to the list
*/
private static IBuildpathEntry[] convert(List list) {
@@ -2137,14 +2151,15 @@ public class BuildpathModifier {
* entries.
*
* @param entry
- * the entry to be validated and added to the list of existing
- * entries.
+ * the entry to be validated and added to the
+ * list of existing entries.
* @param existingEntries
- * a list of existing entries representing the build path
+ * a list of existing entries representing the
+ * build path
* @param project
- * the script project
+ * the script project
* @throws CoreException
- * in case that validation fails
+ * in case that validation fails
*/
private static void validateAndAddEntry(BPListElement entry,
List existingEntries, IScriptProject project) throws CoreException {
@@ -2275,9 +2290,10 @@ public class BuildpathModifier {
* <code>IBuildpathEntry.BPE_SOURCE</code>
*
* @param entry
- * the buildpath entry to be compared with the provided type
+ * the buildpath entry to be compared with the provided
+ * type
* @param kind
- * the kind to be checked
+ * the kind to be checked
* @return <code>true</code> if kind equals
* <code>IBuildpathEntry.BPE_SOURCE</code>, <code>false</code>
* otherwise
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
index 7a1f373e8..520f401a7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
@@ -1,12 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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
*
-
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -17,66 +15,69 @@ import org.eclipse.dltk.core.IMember;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IType;
-
public class CallSearchResultCollector {
- private Map fCalledMembers;
+ private Map fCalledMembers;
- public CallSearchResultCollector() {
- this.fCalledMembers = createCalledMethodsData();
- }
+ public CallSearchResultCollector() {
+ this.fCalledMembers = createCalledMethodsData();
+ }
- public Map getCallers() {
- return fCalledMembers;
- }
+ public Map getCallers() {
+ return fCalledMembers;
+ }
- protected void addMember(IModelElement member, IModelElement calledMember, int start, int end) {
- addMember(member, calledMember, start, end, CallLocation.UNKNOWN_LINE_NUMBER);
- }
+ protected void addMember(IModelElement member, IModelElement calledMember,
+ int start, int end) {
+ addMember(member, calledMember, start, end,
+ CallLocation.UNKNOWN_LINE_NUMBER);
+ }
- protected void addMember(IModelElement member, IModelElement calledMember, int start, int end, int lineNumber) {
- if ((member != null) && (calledMember != null)) {
- if (!isIgnored(calledMember)) {
- MethodCall methodCall = (MethodCall) fCalledMembers.get(calledMember.getHandleIdentifier());
+ protected void addMember(IModelElement member, IModelElement calledMember,
+ int start, int end, int lineNumber) {
+ if ((member != null) && (calledMember != null)) {
+ if (!isIgnored(calledMember)) {
+ MethodCall methodCall = (MethodCall) fCalledMembers
+ .get(calledMember.getHandleIdentifier());
- if (methodCall == null) {
- methodCall = new MethodCall(calledMember);
- fCalledMembers.put(calledMember.getHandleIdentifier(), methodCall);
- }
+ if (methodCall == null) {
+ methodCall = new MethodCall(calledMember);
+ fCalledMembers.put(calledMember.getHandleIdentifier(),
+ methodCall);
+ }
- methodCall.addCallLocation(new CallLocation(member, calledMember, start,
- end, lineNumber));
- }
- }
- }
+ methodCall.addCallLocation(new CallLocation(member,
+ calledMember, start, end, lineNumber));
+ }
+ }
+ }
- protected Map createCalledMethodsData() {
- return new HashMap();
- }
+ protected Map createCalledMethodsData() {
+ return new HashMap();
+ }
- /**
- * Method isIgnored.
- * @param enclosingElement
- * @return boolean
- */
- private boolean isIgnored(IModelElement enclosingElement) {
- IType type = getTypeOfElement(enclosingElement);
- if( type != null ) {
- String fullyQualifiedName = type.getFullyQualifiedName();
+ /**
+ * Method isIgnored.
+ *
+ * @param enclosingElement
+ * @return boolean
+ */
+ private boolean isIgnored(IModelElement enclosingElement) {
+ IType type = getTypeOfElement(enclosingElement);
+ if (type != null) {
+ String fullyQualifiedName = type.getFullyQualifiedName();
- return CallHierarchy.getDefault().isIgnored(fullyQualifiedName);
- }
- else {
- return false;
- }
- }
+ return CallHierarchy.getDefault().isIgnored(fullyQualifiedName);
+ }
+ return false;
+ }
- private IType getTypeOfElement(IModelElement element) {
- if (element.getElementType() == IModelElement.TYPE) {
- return (IType) element;
- }
- if( element instanceof IMember ) {
- return ((IMember)element).getDeclaringType();
- }
- return null;
- }
+ private IType getTypeOfElement(IModelElement element) {
+ if (element.getElementType() == IModelElement.TYPE) {
+ return (IType) element;
+ }
+ if (element instanceof IMember) {
+ return ((IMember) element).getDeclaringType();
+ }
+ return null;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
index f6b8edd9e..99b4d5475 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
@@ -1,12 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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
*
-
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -16,59 +14,57 @@ import java.util.List;
import org.eclipse.dltk.core.IModelElement;
-
public class MethodCall {
- private IModelElement fMember;
- private List fCallLocations;
+ private IModelElement fMember;
+ private List fCallLocations;
+
+ /**
+ * @param enclosingElement
+ */
+ public MethodCall(IModelElement enclosingElement) {
+ this.fMember = enclosingElement;
+ }
- /**
- * @param enclosingElement
- */
- public MethodCall(IModelElement enclosingElement) {
- this.fMember = enclosingElement;
- }
+ /**
+ *
+ */
+ public Collection getCallLocations() {
+ return fCallLocations;
+ }
- /**
- *
- */
- public Collection getCallLocations() {
- return fCallLocations;
- }
+ public CallLocation getFirstCallLocation() {
+ if ((fCallLocations != null) && !fCallLocations.isEmpty()) {
+ return (CallLocation) fCallLocations.get(0);
+ }
+ return null;
+ }
- public CallLocation getFirstCallLocation() {
- if ((fCallLocations != null) && !fCallLocations.isEmpty()) {
- return (CallLocation) fCallLocations.get(0);
- } else {
- return null;
- }
- }
+ public boolean hasCallLocations() {
+ return fCallLocations != null && fCallLocations.size() > 0;
+ }
- public boolean hasCallLocations() {
- return fCallLocations != null && fCallLocations.size() > 0;
- }
-
- /**
- * @return Object
- */
- public Object getKey() {
- return getMember().getHandleIdentifier();
- }
+ /**
+ * @return Object
+ */
+ public Object getKey() {
+ return getMember().getHandleIdentifier();
+ }
- /**
- *
- */
- public IModelElement getMember() {
- return fMember;
- }
+ /**
+ *
+ */
+ public IModelElement getMember() {
+ return fMember;
+ }
- /**
- * @param location
- */
- public void addCallLocation(CallLocation location) {
- if (fCallLocations == null) {
- fCallLocations = new ArrayList();
- }
+ /**
+ * @param location
+ */
+ public void addCallLocation(CallLocation location) {
+ if (fCallLocations == null) {
+ fCallLocations = new ArrayList();
+ }
- fCallLocations.add(location);
- }
+ fCallLocations.add(location);
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
index b34274040..0e8c435c0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 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
*
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -21,300 +20,307 @@ import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.internal.ui.callhierarchy.MethodWrapperWorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter;
-
/**
* This class represents the general parts of a method call (either to or from a
* method).
*
*/
public abstract class MethodWrapper extends PlatformObject {
- private Map fElements = null;
-
- /*
- * A cache of previously found methods. This cache should be searched
- * before adding a "new" method object reference to the list of elements.
- * This way previously found methods won't be searched again.
- */
- private Map fMethodCache;
- private MethodCall fMethodCall;
- private MethodWrapper fParent;
- private int fLevel;
-
- /**
- * Constructor CallerElement.
- */
- public MethodWrapper(MethodWrapper parent, MethodCall methodCall) {
- Assert.isNotNull(methodCall);
-
- if (parent == null) {
- setMethodCache(new HashMap());
- fLevel = 1;
- } else {
- setMethodCache(parent.getMethodCache());
- fLevel = parent.getLevel() + 1;
- }
-
- this.fMethodCall = methodCall;
- this.fParent = parent;
- }
+ private Map fElements = null;
+
+ /*
+ * A cache of previously found methods. This cache should be searched before
+ * adding a "new" method object reference to the list of elements. This way
+ * previously found methods won't be searched again.
+ */
+ private Map fMethodCache;
+ private MethodCall fMethodCall;
+ private MethodWrapper fParent;
+ private int fLevel;
+
+ /**
+ * Constructor CallerElement.
+ */
+ public MethodWrapper(MethodWrapper parent, MethodCall methodCall) {
+ Assert.isNotNull(methodCall);
+
+ if (parent == null) {
+ setMethodCache(new HashMap());
+ fLevel = 1;
+ } else {
+ setMethodCache(parent.getMethodCache());
+ fLevel = parent.getLevel() + 1;
+ }
+
+ this.fMethodCall = methodCall;
+ this.fParent = parent;
+ }
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IModelElement.class) {
return (T) getMember();
- } else if (adapter == IWorkbenchAdapter.class){
+ } else if (adapter == IWorkbenchAdapter.class) {
return (T) new MethodWrapperWorkbenchAdapter(this);
- } else {
- return null;
- }
+ } else {
+ return null;
+ }
}
- /**
- * @return the child caller elements of this element
- */
- public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
- if (fElements == null) {
- doFindChildren(progressMonitor);
- }
-
- MethodWrapper[] result = new MethodWrapper[fElements.size()];
- int i = 0;
-
- for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
- MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
- result[i++] = createMethodWrapper(methodCall);
- }
-
- return result;
- }
-
- public int getLevel() {
- return fLevel;
- }
-
- public IModelElement getMember() {
- return getMethodCall().getMember();
- }
-
- public MethodCall getMethodCall() {
- return fMethodCall;
- }
-
- public String getName() {
- if (getMethodCall() != null) {
- return getMethodCall().getMember().getElementName();
- } else {
- return ""; //$NON-NLS-1$
- }
- }
-
- public MethodWrapper getParent() {
- return fParent;
- }
+ /**
+ * @return the child caller elements of this element
+ */
+ public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
+ if (fElements == null) {
+ doFindChildren(progressMonitor);
+ }
+
+ MethodWrapper[] result = new MethodWrapper[fElements.size()];
+ int i = 0;
+
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ MethodCall methodCall = getMethodCallFromMap(fElements,
+ iter.next());
+ result[i++] = createMethodWrapper(methodCall);
+ }
+
+ return result;
+ }
+
+ public int getLevel() {
+ return fLevel;
+ }
+
+ public IModelElement getMember() {
+ return getMethodCall().getMember();
+ }
+
+ public MethodCall getMethodCall() {
+ return fMethodCall;
+ }
+
+ public String getName() {
+ if (getMethodCall() != null) {
+ return getMethodCall().getMember().getElementName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public MethodWrapper getParent() {
+ return fParent;
+ }
@Override
public boolean equals(Object oth) {
- if (this == oth) {
- return true;
- }
-
- if (oth == null) {
- return false;
- }
-
- if (oth instanceof MethodWrapperWorkbenchAdapter) {
- //Note: A MethodWrapper is equal to a referring MethodWrapperWorkbenchAdapter and vice versa (bug 101677).
- oth= ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper();
- }
-
- if (oth.getClass() != getClass()) {
- return false;
- }
-
- MethodWrapper other = (MethodWrapper) oth;
-
- if (this.fParent == null) {
- if (other.fParent != null) {
- return false;
- }
- } else {
- if (!this.fParent.equals(other.fParent)) {
- return false;
- }
- }
-
- if (this.getMethodCall() == null) {
- if (other.getMethodCall() != null) {
- return false;
- }
- } else {
- if (!this.getMethodCall().equals(other.getMethodCall())) {
- return false;
- }
- }
-
- return true;
- }
+ if (this == oth) {
+ return true;
+ }
+
+ if (oth == null) {
+ return false;
+ }
+
+ if (oth instanceof MethodWrapperWorkbenchAdapter) {
+ // Note: A MethodWrapper is equal to a referring
+ // MethodWrapperWorkbenchAdapter and vice versa (bug 101677).
+ oth = ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper();
+ }
+
+ if (oth.getClass() != getClass()) {
+ return false;
+ }
+
+ MethodWrapper other = (MethodWrapper) oth;
+
+ if (this.fParent == null) {
+ if (other.fParent != null) {
+ return false;
+ }
+ } else {
+ if (!this.fParent.equals(other.fParent)) {
+ return false;
+ }
+ }
+
+ if (this.getMethodCall() == null) {
+ if (other.getMethodCall() != null) {
+ return false;
+ }
+ } else {
+ if (!this.getMethodCall().equals(other.getMethodCall())) {
+ return false;
+ }
+ }
+
+ return true;
+ }
@Override
public int hashCode() {
- final int PRIME = 1000003;
- int result = 0;
-
- if (fParent != null) {
- result = (PRIME * result) + fParent.hashCode();
- }
-
- if (getMethodCall() != null) {
- result = (PRIME * result) + getMethodCall().getMember().hashCode();
- }
-
- return result;
- }
-
- private void setMethodCache(Map methodCache) {
- fMethodCache = methodCache;
- }
-
- protected abstract String getTaskName();
-
- private void addCallToCache(MethodCall methodCall) {
- Map cachedCalls = lookupMethod(this.getMethodCall());
- cachedCalls.put(methodCall.getKey(), methodCall);
- }
-
- protected abstract MethodWrapper createMethodWrapper(MethodCall methodCall);
-
- private void doFindChildren(IProgressMonitor progressMonitor) {
- Map existingResults = lookupMethod(getMethodCall());
-
- if (existingResults != null) {
- fElements = new HashMap();
- fElements.putAll(existingResults);
- } else {
- initCalls();
-
- if (progressMonitor != null) {
- progressMonitor.beginTask(getTaskName(), 100);
- }
-
- try {
- performSearch(progressMonitor);
- } finally {
- if (progressMonitor != null) {
- progressMonitor.done();
- }
- }
-
- // ModalContext.run(getRunnableWithProgress(), true, getProgressMonitor(),
- // Display.getCurrent());
- }
- }
-
- /**
- * Determines if the method represents a recursion call (i.e. whether the
- * method call is already in the cache.)
- *
- * @return True if the call is part of a recursion
- */
- public boolean isRecursive() {
- MethodWrapper current = getParent();
-
- while (current != null) {
- if (getMember().getHandleIdentifier().equals(current.getMember()
- .getHandleIdentifier())) {
- return true;
- }
-
- current = current.getParent();
- }
-
- return false;
- }
-
- /**
- * This method finds the children of the current IMethod (either callers or
- * callees, depending on the concrete subclass.
- * @return The result of the search for children
- */
- protected abstract Map findChildren(IProgressMonitor progressMonitor);
-
- private Map getMethodCache() {
- return fMethodCache;
- }
-
- private void initCalls() {
- this.fElements = new HashMap();
-
- initCacheForMethod();
- }
-
- /**
- * Looks up a previously created search result in the "global" cache.
- * @return the List of previously found search results
- */
- private Map lookupMethod(MethodCall methodCall) {
- return (Map) getMethodCache().get(methodCall.getKey());
- }
-
- private void performSearch(IProgressMonitor progressMonitor) {
- fElements = findChildren(progressMonitor);
-
- for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
- checkCanceled(progressMonitor);
-
- MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
- addCallToCache(methodCall);
- }
- }
-
- private MethodCall getMethodCallFromMap(Map elements, Object key) {
- return (MethodCall) elements.get(key);
- }
-
- private void initCacheForMethod() {
- Map cachedCalls = new HashMap();
- getMethodCache().put(this.getMethodCall().getKey(), cachedCalls);
- }
-
- /**
- * Checks with the progress monitor to see whether the creation of the type hierarchy
- * should be canceled. Should be regularly called
- * so that the user can cancel.
- *
- * @exception OperationCanceledException if cancelling the operation has been requested
- * @see IProgressMonitor#isCanceled
- */
- protected void checkCanceled(IProgressMonitor progressMonitor) {
- if (progressMonitor != null && progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
-
- /**
- * Allows a visitor to traverse the call hierarchy. The visiting is stopped when
- * a recursive node is reached.
- *
- * @param visitor
- */
- public void accept(CallHierarchyVisitor visitor, IProgressMonitor progressMonitor) {
- if (getParent() != null && getParent().isRecursive()) {
- return;
- }
- checkCanceled(progressMonitor);
-
- visitor.preVisit(this);
- if (visitor.visit(this)) {
- MethodWrapper[] methodWrappers= getCalls(progressMonitor);
- for (int i= 0; i < methodWrappers.length; i++) {
- methodWrappers[i].accept(visitor, progressMonitor);
- }
- }
- visitor.postVisit(this);
-
- if (progressMonitor != null) {
- progressMonitor.worked(1);
- }
- }
+ final int PRIME = 1000003;
+ int result = 0;
+
+ if (fParent != null) {
+ result = (PRIME * result) + fParent.hashCode();
+ }
+
+ if (getMethodCall() != null) {
+ result = (PRIME * result) + getMethodCall().getMember().hashCode();
+ }
+
+ return result;
+ }
+
+ private void setMethodCache(Map methodCache) {
+ fMethodCache = methodCache;
+ }
+
+ protected abstract String getTaskName();
+
+ private void addCallToCache(MethodCall methodCall) {
+ Map cachedCalls = lookupMethod(this.getMethodCall());
+ cachedCalls.put(methodCall.getKey(), methodCall);
+ }
+
+ protected abstract MethodWrapper createMethodWrapper(MethodCall methodCall);
+
+ private void doFindChildren(IProgressMonitor progressMonitor) {
+ Map existingResults = lookupMethod(getMethodCall());
+
+ if (existingResults != null) {
+ fElements = new HashMap();
+ fElements.putAll(existingResults);
+ } else {
+ initCalls();
+
+ if (progressMonitor != null) {
+ progressMonitor.beginTask(getTaskName(), 100);
+ }
+
+ try {
+ performSearch(progressMonitor);
+ } finally {
+ if (progressMonitor != null) {
+ progressMonitor.done();
+ }
+ }
+
+ // ModalContext.run(getRunnableWithProgress(), true,
+ // getProgressMonitor(),
+ // Display.getCurrent());
+ }
+ }
+
+ /**
+ * Determines if the method represents a recursion call (i.e. whether the
+ * method call is already in the cache.)
+ *
+ * @return True if the call is part of a recursion
+ */
+ public boolean isRecursive() {
+ MethodWrapper current = getParent();
+
+ while (current != null) {
+ if (getMember().getHandleIdentifier()
+ .equals(current.getMember().getHandleIdentifier())) {
+ return true;
+ }
+
+ current = current.getParent();
+ }
+
+ return false;
+ }
+
+ /**
+ * This method finds the children of the current IMethod (either callers or
+ * callees, depending on the concrete subclass.
+ *
+ * @return The result of the search for children
+ */
+ protected abstract Map findChildren(IProgressMonitor progressMonitor);
+
+ private Map getMethodCache() {
+ return fMethodCache;
+ }
+
+ private void initCalls() {
+ this.fElements = new HashMap();
+
+ initCacheForMethod();
+ }
+
+ /**
+ * Looks up a previously created search result in the "global" cache.
+ *
+ * @return the List of previously found search results
+ */
+ private Map lookupMethod(MethodCall methodCall) {
+ return (Map) getMethodCache().get(methodCall.getKey());
+ }
+
+ private void performSearch(IProgressMonitor progressMonitor) {
+ fElements = findChildren(progressMonitor);
+
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ checkCanceled(progressMonitor);
+
+ MethodCall methodCall = getMethodCallFromMap(fElements,
+ iter.next());
+ addCallToCache(methodCall);
+ }
+ }
+
+ private MethodCall getMethodCallFromMap(Map elements, Object key) {
+ return (MethodCall) elements.get(key);
+ }
+
+ private void initCacheForMethod() {
+ Map cachedCalls = new HashMap();
+ getMethodCache().put(this.getMethodCall().getKey(), cachedCalls);
+ }
+
+ /**
+ * Checks with the progress monitor to see whether the creation of the type
+ * hierarchy should be canceled. Should be regularly called so that the user
+ * can cancel.
+ *
+ * @exception OperationCanceledException
+ * if cancelling the operation has
+ * been requested
+ * @see IProgressMonitor#isCanceled
+ */
+ protected void checkCanceled(IProgressMonitor progressMonitor) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ }
+
+ /**
+ * Allows a visitor to traverse the call hierarchy. The visiting is stopped
+ * when a recursive node is reached.
+ *
+ * @param visitor
+ */
+ public void accept(CallHierarchyVisitor visitor,
+ IProgressMonitor progressMonitor) {
+ if (getParent() != null && getParent().isRecursive()) {
+ return;
+ }
+ checkCanceled(progressMonitor);
+
+ visitor.preVisit(this);
+ if (visitor.visit(this)) {
+ MethodWrapper[] methodWrappers = getCalls(progressMonitor);
+ for (int i = 0; i < methodWrappers.length; i++) {
+ methodWrappers[i].accept(visitor, progressMonitor);
+ }
+ }
+ visitor.postVisit(this);
+
+ if (progressMonitor != null) {
+ progressMonitor.worked(1);
+ }
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
index ab6cd757e..9dbeb3df8 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.util;
@@ -13,16 +12,12 @@ import com.ibm.icu.text.MessageFormat;
/**
* Helper class to format message strings.
- *
- *
+ *
+ *
*/
public class Messages {
- public static String format(String message, Object object) {
- return MessageFormat.format(message, new Object[] { object});
- }
-
- public static String format(String message, Object[] objects) {
+ public static String format(String message, Object... objects) {
return MessageFormat.format(message, objects);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java
index 7314a819d..a3c802873 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.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
@@ -12,38 +12,40 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.ModelException;
-
/**
- * This class locates different resources
- * which are related to an object
+ * This class locates different resources which are related to an object
*/
public class ResourceLocator implements IResourceLocator {
@Override
- public IResource getUnderlyingResource(Object element) throws ModelException {
- if (element instanceof IModelElement)
+ public IResource getUnderlyingResource(Object element)
+ throws ModelException {
+ if (element instanceof IModelElement) {
return ((IModelElement) element).getUnderlyingResource();
- else
- return null;
+ }
+ return null;
}
@Override
- public IResource getCorrespondingResource(Object element) throws ModelException {
- if (element instanceof IModelElement)
+ public IResource getCorrespondingResource(Object element)
+ throws ModelException {
+ if (element instanceof IModelElement) {
return ((IModelElement) element).getCorrespondingResource();
- else
- return null;
+ }
+ return null;
}
@Override
- public IResource getContainingResource(Object element) throws ModelException {
- IResource resource= null;
+ public IResource getContainingResource(Object element)
+ throws ModelException {
+ IResource resource = null;
if (element instanceof IResource)
- resource= (IResource) element;
+ resource = (IResource) element;
if (element instanceof IModelElement) {
- resource= ((IModelElement) element).getResource();
+ resource = ((IModelElement) element).getResource();
if (resource == null)
- resource= ((IModelElement) element).getScriptProject().getProject();
+ resource = ((IModelElement) element).getScriptProject()
+ .getProject();
}
return resource;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
index 173ea9b2a..bee98dcf3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.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
@@ -107,8 +107,8 @@ public class StandardModelElementContentProvider
* Creates a new <code>StandardJavaElementContentProvider</code>.
*
* @param provideMembers
- * if <code>true</code> members below compilation units and class
- * files are provided.
+ * if <code>true</code> members below compilation
+ * units and class files are provided.
*/
public StandardModelElementContentProvider(boolean provideMembers) {
fProvideMembers = provideMembers;
@@ -131,9 +131,9 @@ public class StandardModelElementContentProvider
* asking a compilation unit or class file for its children.
*
* @param b
- * if <code>true</code> then members are provided. If
- * <code>false</code> compilation units and class files are the
- * leaves provided by this content provider.
+ * if <code>true</code> then members are provided. If
+ * <code>false</code> compilation units and class files are the
+ * leaves provided by this content provider.
*/
public void setProvideMembers(boolean b) {
fProvideMembers = b;
@@ -167,9 +167,8 @@ public class StandardModelElementContentProvider
providers[i].provideModelChanges(element, elements, this);
}
return elements.toArray();
- } else {
- return children;
}
+ return children;
}
private String getToolkitID(Object element) {
@@ -302,12 +301,12 @@ public class StandardModelElementContentProvider
* can override this method.
*
* @param root
- * The root to evaluate the children for.
+ * The root to evaluate the children for.
* @return The children of the root
* @exception JavaModelException
- * if the package fragment root does not exist or if an
- * exception occurs while accessing its corresponding
- * resource
+ * if the package fragment root does not
+ * exist or if an exception occurs while
+ * accessing its corresponding resource
*
*/
protected Object[] getProjectFragmentContent(IProjectFragment root)
@@ -345,12 +344,13 @@ public class StandardModelElementContentProvider
* override this method.
*
* @param project
- * The Java project to evaluate the children for.
+ * The Java project to evaluate the children for.
* @return The children of the project. Typically these are package fragment
* roots but can also be other elements.
* @exception JavaModelException
- * if the Java project does not exist or if an exception
- * occurs while accessing its corresponding resource
+ * if the Java project does not exist or
+ * if an exception occurs while accessing
+ * its corresponding resource
*/
protected Object[] getProjectFragments(IScriptProject project)
throws ModelException {
@@ -393,11 +393,12 @@ public class StandardModelElementContentProvider
* override this method.
*
* @param fragment
- * The fragment to evaluate the children for.
+ * The fragment to evaluate the children for.
* @return The children of the given package fragment.
* @exception JavaModelException
- * if the package fragment does not exist or if an exception
- * occurs while accessing its corresponding resource
+ * if the package fragment does not exist
+ * or if an exception occurs while
+ * accessing its corresponding resource
*
* @since 3.3
*/
@@ -416,10 +417,10 @@ public class StandardModelElementContentProvider
* this method.
*
* @param folder
- * The folder to evaluate the children for.
+ * The folder to evaluate the children for.
* @return The children of the given package fragment.
* @exception CoreException
- * if the folder does not exist.
+ * if the folder does not exist.
*
*/
protected Object[] getFolderContent(IFolder folder) throws CoreException {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
index 7eaac0247..2745e8566 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.actions;
@@ -116,18 +115,15 @@ public class ActionUtil {
return false;
}
- public static boolean areProcessable(Shell shell, IModelElement[] elements) {
+ public static boolean areProcessable(Shell shell,
+ IModelElement[] elements) {
for (int i = 0; i < elements.length; i++) {
if (!isOnBuildPath(elements[i])) {
- MessageDialog
- .openInformation(
- shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- Messages
- .format(
- ActionMessages.ActionUtil_notOnBuildPath_resource_message,
- new Object[] { elements[i]
- .getPath() }));
+ MessageDialog.openInformation(shell,
+ ActionMessages.ActionUtil_notOnBuildPath_title,
+ Messages.format(
+ ActionMessages.ActionUtil_notOnBuildPath_resource_message,
+ new Object[] { elements[i].getPath() }));
return false;
}
}
@@ -139,14 +135,14 @@ public class ActionUtil {
* processable and editable. If the editor edits the element, the validation
* is only performed once. If necessary, ask the user whether the file(s)
* should be edited.
- *
+ *
* @param editor
- * an editor, or <code>null</code> iff the action was not
- * executed from an editor
+ * an editor, or <code>null</code> iff the action was not
+ * executed from an editor
* @param shell
- * a shell to serve as parent for a dialog
+ * a shell to serve as parent for a dialog
* @param element
- * the element to check, cannot be <code>null</code>
+ * the element to check, cannot be <code>null</code>
* @return <code>true</code> if the element can be edited,
* <code>false</code> otherwise
*/
@@ -154,12 +150,11 @@ public class ActionUtil {
IModelElement element) {
if (editor != null) {
IModelElement input = SelectionConverter.getInput(editor);
- if (input != null
- && input.equals(element
- .getAncestor(IModelElement.SOURCE_MODULE)))
+ if (input != null && input
+ .equals(element.getAncestor(IModelElement.SOURCE_MODULE))) {
return isEditable(editor);
- else
- return isEditable(editor) && isEditable(shell, element);
+ }
+ return isEditable(editor) && isEditable(shell, element);
}
return isEditable(shell, element);
}
@@ -191,16 +186,12 @@ public class ActionUtil {
return true;
MessageDialogWithToggle toggleDialog = MessageDialogWithToggle
- .openYesNoQuestion(
- shell,
+ .openYesNoQuestion(shell,
ActionMessages.ActionUtil_warning_derived_title,
- Messages
- .format(
- ActionMessages.ActionUtil_warning_derived_message,
- BasicElementLabels
- .getPathLabel(resource
- .getFullPath(),
- false)),
+ Messages.format(
+ ActionMessages.ActionUtil_warning_derived_message,
+ BasicElementLabels.getPathLabel(
+ resource.getFullPath(), false)),
ActionMessages.ActionUtil_warning_derived_dontShowAgain,
false, null, null);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java
index bbdafa9a8..d05cda4ef 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.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
@@ -43,7 +43,8 @@ public abstract class QuickMenuAction extends Action {
* Creates a new quick menu action with the given command id.
*
* @param commandId
- * the command id of the short cut used to open the sub menu
+ * the command id of the short cut used to open the sub
+ * menu
*/
public QuickMenuAction(String commandId) {
setActionDefinitionId(commandId);
@@ -79,7 +80,7 @@ public abstract class QuickMenuAction extends Action {
* Hook to fill a menu manager with the items of the sub menu.
*
* @param menu
- * the sub menu to fill
+ * the sub menu to fill
*/
protected abstract void fillMenu(IMenuManager menu);
@@ -87,7 +88,7 @@ public abstract class QuickMenuAction extends Action {
* Adds the shortcut to the given menu text and returns it.
*
* @param menuText
- * the menu text
+ * the menu text
* @return the menu text with the shortcut
* @since 3.1
*/
@@ -152,7 +153,7 @@ public abstract class QuickMenuAction extends Action {
* widget.
*
* @param text
- * the styled text widget that has the focus
+ * the styled text widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -171,7 +172,7 @@ public abstract class QuickMenuAction extends Action {
* Hook to compute the menu location if the focus widget is a tree widget.
*
* @param tree
- * the tree widget that has the focus
+ * the tree widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -192,9 +193,8 @@ public abstract class QuickMenuAction extends Action {
bounds.x + getAvarageCharWith(tree)
* CHAR_INDENT),
bounds.y + bounds.height);
- } else {
- return null;
}
+ return null;
default:
Rectangle[] rectangles = new Rectangle[items.length];
for (int i = 0; i < rectangles.length; i++) {
@@ -214,7 +214,7 @@ public abstract class QuickMenuAction extends Action {
* Hook to compute the menu location if the focus widget is a table widget.
*
* @param table
- * the table widget that has the focus
+ * the table widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -238,9 +238,8 @@ public abstract class QuickMenuAction extends Action {
+ getAvarageCharWith(table)
* CHAR_INDENT),
bounds.y + bounds.height);
- } else {
- return null;
}
+ return null;
}
default: {
Rectangle[] rectangles = new Rectangle[items.length];
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java
index db3f0d16d..cd1161f2d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.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
@@ -120,8 +120,8 @@ public class SelectionConverter {
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
public static IModelElement[] codeResolve(IEditorPart editor,
@@ -134,8 +134,8 @@ public class SelectionConverter {
* Perform a code resolve in a separate thread.
*
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
* @throws InterruptedException
* @throws InvocationTargetException
*
@@ -161,8 +161,8 @@ public class SelectionConverter {
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
private static IModelElement getElementAtOffset(IEditorPart editor,
@@ -188,9 +188,8 @@ public class SelectionConverter {
if (editor instanceof ITextEditor) {
return (ITextSelection) ((ITextEditor) editor)
.getSelectionProvider().getSelection();
- } else {
- return TextSelection.emptySelection();
}
+ return TextSelection.emptySelection();
}
public static IModelElement getInput(IEditorPart editor) {
@@ -199,8 +198,8 @@ public class SelectionConverter {
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
private static IModelElement getInput(IEditorPart editor,
@@ -329,10 +328,10 @@ public class SelectionConverter {
ISourceModule cunit = (ISourceModule) input;
ScriptModelUtil.reconcile(cunit);
IModelElement ref = cunit.getElementAt(selection.getOffset());
- if (ref == null)
+ if (ref == null) {
return input;
- else
- return ref;
+ }
+ return ref;
}
return null;
}
@@ -367,23 +366,21 @@ public class SelectionConverter {
}
if (atOffset == null) {
return input;
- } else {
- int selectionEnd = selection.getOffset() + selection.getLength();
- IModelElement result = atOffset;
- if (atOffset instanceof ISourceReference) {
- ISourceRange range = ((ISourceReference) atOffset)
- .getSourceRange();
- while (range.getOffset() + range.getLength() < selectionEnd) {
- result = result.getParent();
- if (!(result instanceof ISourceReference)) {
- result = input;
- break;
- }
- range = ((ISourceReference) result).getSourceRange();
+ }
+ int selectionEnd = selection.getOffset() + selection.getLength();
+ IModelElement result = atOffset;
+ if (atOffset instanceof ISourceReference) {
+ ISourceRange range = ((ISourceReference) atOffset).getSourceRange();
+ while (range.getOffset() + range.getLength() < selectionEnd) {
+ result = result.getParent();
+ if (!(result instanceof ISourceReference)) {
+ result = input;
+ break;
}
+ range = ((ISourceReference) result).getSourceRange();
}
- return result;
}
+ return result;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java
index 4ad034ae0..7b4676f5d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.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
@@ -24,15 +24,17 @@ import org.eclipse.dltk.internal.ui.DLTKUIStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.IThreadListener;
-
/**
- * An <code>IRunnableWithProgress</code> that adapts and <code>IWorkspaceRunnable</code>
- * so that is can be executed inside <code>IRunnableContext</code>. <code>OperationCanceledException</code>
- * thrown by the adapted runnable are caught and re-thrown as a <code>InterruptedException</code>.
+ * An <code>IRunnableWithProgress</code> that adapts and
+ * <code>IWorkspaceRunnable</code> so that is can be executed inside
+ * <code>IRunnableContext</code>. <code>OperationCanceledException</code> thrown
+ * by the adapted runnable are caught and re-thrown as a
+ * <code>InterruptedException</code>.
*/
-public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener {
+public class WorkbenchRunnableAdapter
+ implements IRunnableWithProgress, IThreadListener {
- private boolean fTransfer= false;
+ private boolean fTransfer = false;
private IWorkspaceRunnable fWorkspaceRunnable;
private ISchedulingRule fRule;
@@ -44,22 +46,29 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
/**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
+ * Runs a workspace runnable with the given lock or <code>null</code> to run
+ * with no lock at all.
*/
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
+ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable,
+ ISchedulingRule rule) {
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
}
/**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
- * @param transfer <code>true</code> if the rule is to be transfered
- * to the model context thread. Otherwise <code>false</code>
+ * Runs a workspace runnable with the given lock or <code>null</code> to run
+ * with no lock at all.
+ *
+ * @param transfer
+ * <code>true</code> if the rule is to be transfered to
+ * the model context thread. Otherwise
+ * <code>false</code>
*/
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- fTransfer= transfer;
+ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable,
+ ISchedulingRule rule, boolean transfer) {
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
+ fTransfer = transfer;
}
public ISchedulingRule getSchedulingRule() {
@@ -73,7 +82,8 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
try {
DLTKCore.run(fWorkspaceRunnable, fRule, monitor);
} catch (OperationCanceledException e) {
@@ -84,18 +94,17 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
public void runAsUserJob(String name, final Object jobFamiliy) {
- Job buildJob = new Job(name){
+ Job buildJob = new Job(name) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
WorkbenchRunnableAdapter.this.run(monitor);
} catch (InvocationTargetException e) {
- Throwable cause= e.getCause();
+ Throwable cause = e.getCause();
if (cause instanceof CoreException) {
return ((CoreException) cause).getStatus();
- } else {
- return DLTKUIStatus.createError(IStatus.ERROR, cause);
}
+ return DLTKUIStatus.createError(IStatus.ERROR, cause);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
} finally {
@@ -103,6 +112,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL
}
return Status.OK_STATUS;
}
+
@Override
public boolean belongsTo(Object family) {
return jobFamiliy == family;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java
index b20334126..1514a220e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.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
@@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IWorkbenchSite;
-
/**
* Renames a Script element or workbench resource.
* <p>
@@ -33,7 +32,7 @@ import org.eclipse.ui.IWorkbenchSite;
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
- *
+ *
*/
public class RenameAction extends SelectionDispatchAction {
@@ -43,34 +42,39 @@ public class RenameAction extends SelectionDispatchAction {
private ScriptEditor fEditor;
/**
- * Creates a new <code>RenameAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
+ * Creates a new <code>RenameAction</code>. The action requires that the
+ * selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
- * @param site the site providing context information for this action
+ * @param site
+ * the site providing context information for this action
*/
public RenameAction(IWorkbenchSite site) {
super(site);
setText(RefactoringMessages.RenameAction_text);
- fRenameScriptElement= new RenameModelElementAction(site);
+ fRenameScriptElement = new RenameModelElementAction(site);
fRenameScriptElement.setText(getText());
- fRenameResource= new RenameResourceAction(site);
+ fRenameResource = new RenameResourceAction(site);
fRenameResource.setText(getText());
if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
}
- // PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IScriptHelpContextIds.RENAME_ACTION);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ // IScriptHelpContextIds.RENAME_ACTION);
}
/**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- * @param editor the compilation unit editor
+ * Note: This constructor is for internal use only. Clients should not call
+ * this constructor.
+ *
+ * @param editor
+ * the compilation unit editor
*/
public RenameAction(ScriptEditor editor) {
this(editor.getEditorSite());
- fEditor= editor;
- fRenameScriptElement= new RenameModelElementAction(editor);
+ fEditor = editor;
+ fRenameScriptElement = new RenameModelElementAction(editor);
}
@Override
@@ -91,12 +95,12 @@ public class RenameAction extends SelectionDispatchAction {
setEnabled(computeEnabledState());
}
- private boolean computeEnabledState(){
+ private boolean computeEnabledState() {
if (fRenameResource != null) {
- return fRenameScriptElement.isEnabled() || fRenameResource.isEnabled();
- } else {
- return fRenameScriptElement.isEnabled();
+ return fRenameScriptElement.isEnabled()
+ || fRenameResource.isEnabled();
}
+ return fRenameScriptElement.isEnabled();
}
@Override
@@ -114,6 +118,8 @@ public class RenameAction extends SelectionDispatchAction {
if (fRenameScriptElement.canRun())
fRenameScriptElement.run(selection);
else
- MessageDialog.openInformation(getShell(), RefactoringMessages.RenameAction_rename, RefactoringMessages.RenameAction_unavailable);
+ MessageDialog.openInformation(getShell(),
+ RefactoringMessages.RenameAction_rename,
+ RefactoringMessages.RenameAction_unavailable);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java
index cec2e8277..eb75c88cc 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.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
@@ -115,11 +115,10 @@ public class LogicalPackage extends PlatformObject {
}
private int getHash(IScriptFolder[] fragments, int index) {
- if (index <= 0)
+ if (index <= 0) {
return fragments[0].hashCode() * 17;
- else
- return fragments[index].hashCode() * 17
- + getHash(fragments, index - 1);
+ }
+ return fragments[index].hashCode() * 17 + getHash(fragments, index - 1);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java
index d7e1c95d2..9c1efa0e5 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.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
@@ -22,124 +22,129 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.progress.DeferredTreeContentManager;
-
public class CallHierarchyContentProvider implements ITreeContentProvider {
- private final static Object[] EMPTY_ARRAY = new Object[0];
+ private final static Object[] EMPTY_ARRAY = new Object[0];
- private DeferredTreeContentManager fManager;
- private CallHierarchyViewPart fPart;
+ private DeferredTreeContentManager fManager;
+ private CallHierarchyViewPart fPart;
- private class MethodWrapperRunnable implements IRunnableWithProgress {
- private MethodWrapper fMethodWrapper;
- private MethodWrapper[] fCalls= null;
+ private class MethodWrapperRunnable implements IRunnableWithProgress {
+ private MethodWrapper fMethodWrapper;
+ private MethodWrapper[] fCalls = null;
- MethodWrapperRunnable(MethodWrapper methodWrapper) {
- fMethodWrapper= methodWrapper;
- }
+ MethodWrapperRunnable(MethodWrapper methodWrapper) {
+ fMethodWrapper = methodWrapper;
+ }
- @Override
+ @Override
public void run(IProgressMonitor pm) {
- fCalls= fMethodWrapper.getCalls(pm);
- }
-
- MethodWrapper[] getCalls() {
- if (fCalls != null) {
- return fCalls;
- }
- return new MethodWrapper[0];
- }
- }
-
- public CallHierarchyContentProvider(CallHierarchyViewPart part) {
- super();
- fPart= part;
- }
-
- @Override
+ fCalls = fMethodWrapper.getCalls(pm);
+ }
+
+ MethodWrapper[] getCalls() {
+ if (fCalls != null) {
+ return fCalls;
+ }
+ return new MethodWrapper[0];
+ }
+ }
+
+ public CallHierarchyContentProvider(CallHierarchyViewPart part) {
+ super();
+ fPart = part;
+ }
+
+ @Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeRoot) {
- TreeRoot dummyRoot = (TreeRoot) parentElement;
-
- return new Object[] { dummyRoot.getRoot() };
- } else if (parentElement instanceof MethodWrapper) {
- MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
-
- if (shouldStopTraversion(methodWrapper)) {
- return EMPTY_ARRAY;
- } else {
- if (fManager != null) {
- Object[] children = fManager.getChildren(new DeferredMethodWrapper(this, methodWrapper));
- if (children != null)
- return children;
- }
- return fetchChildren(methodWrapper);
- }
- }
-
- return EMPTY_ARRAY;
- }
-
- protected Object[] fetchChildren(MethodWrapper methodWrapper) {
- IRunnableContext context= DLTKUIPlugin.getActiveWorkbenchWindow();
- MethodWrapperRunnable runnable= new MethodWrapperRunnable(methodWrapper);
- try {
- context.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, CallHierarchyMessages.CallHierarchyContentProvider_searchError_title, CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);
- return EMPTY_ARRAY;
- } catch (InterruptedException e) {
- return new Object[] { TreeTermination.SEARCH_CANCELED };
- }
-
- return runnable.getCalls();
- }
-
- private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
- return (methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth()) || methodWrapper.isRecursive();
- }
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- @Override
+ if (parentElement instanceof TreeRoot) {
+ TreeRoot dummyRoot = (TreeRoot) parentElement;
+
+ return new Object[] { dummyRoot.getRoot() };
+ } else if (parentElement instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
+
+ if (shouldStopTraversion(methodWrapper)) {
+ return EMPTY_ARRAY;
+ }
+ if (fManager != null) {
+ Object[] children = fManager.getChildren(
+ new DeferredMethodWrapper(this, methodWrapper));
+ if (children != null)
+ return children;
+ }
+ return fetchChildren(methodWrapper);
+ }
+
+ return EMPTY_ARRAY;
+ }
+
+ protected Object[] fetchChildren(MethodWrapper methodWrapper) {
+ IRunnableContext context = DLTKUIPlugin.getActiveWorkbenchWindow();
+ MethodWrapperRunnable runnable = new MethodWrapperRunnable(
+ methodWrapper);
+ try {
+ context.run(true, true, runnable);
+ } catch (InvocationTargetException e) {
+ ExceptionHandler.handle(e,
+ CallHierarchyMessages.CallHierarchyContentProvider_searchError_title,
+ CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);
+ return EMPTY_ARRAY;
+ } catch (InterruptedException e) {
+ return new Object[] { TreeTermination.SEARCH_CANCELED };
+ }
+
+ return runnable.getCalls();
+ }
+
+ private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
+ return (methodWrapper.getLevel() > CallHierarchyUI.getDefault()
+ .getMaxCallDepth()) || methodWrapper.isRecursive();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
+ return getChildren(inputElement);
+ }
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
public Object getParent(Object element) {
- if (element instanceof MethodWrapper) {
- return ((MethodWrapper) element).getParent();
- }
+ if (element instanceof MethodWrapper) {
+ return ((MethodWrapper) element).getParent();
+ }
- return null;
- }
+ return null;
+ }
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
public void dispose() {
- // Nothing to dispose
- }
+ // Nothing to dispose
+ }
- /**
+ /**
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
public boolean hasChildren(Object element) {
- if (element == TreeRoot.EMPTY_ROOT || element == TreeTermination.SEARCH_CANCELED) {
+ if (element == TreeRoot.EMPTY_ROOT
+ || element == TreeTermination.SEARCH_CANCELED) {
return false;
}
// Only methods can have subelements, so there's no need to fool the
// user into believing that there is more
if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper= (MethodWrapper) element;
- if (methodWrapper.getMember().getElementType() != IModelElement.METHOD) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
+ if (methodWrapper.getMember()
+ .getElementType() != IModelElement.METHOD) {
return false;
}
if (shouldStopTraversion(methodWrapper)) {
@@ -159,45 +164,45 @@ public class CallHierarchyContentProvider implements ITreeContentProvider {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput instanceof TreeRoot) {
- Object root = ((TreeRoot) oldInput).getRoot();
- if (root instanceof MethodWrapper) {
- cancelJobs((MethodWrapper) root);
- }
- }
- if (viewer instanceof AbstractTreeViewer) {
+ if (oldInput instanceof TreeRoot) {
+ Object root = ((TreeRoot) oldInput).getRoot();
+ if (root instanceof MethodWrapper) {
+ cancelJobs((MethodWrapper) root);
+ }
+ }
+ if (viewer instanceof AbstractTreeViewer) {
fManager = new DeferredTreeContentManager(
(AbstractTreeViewer) viewer, fPart.getSite());
- }
- }
-
- /**
- * Cancel all current jobs.
- */
- void cancelJobs(MethodWrapper wrapper) {
- if (fManager != null && wrapper != null) {
+ }
+ }
+
+ /**
+ * Cancel all current jobs.
+ */
+ void cancelJobs(MethodWrapper wrapper) {
+ if (fManager != null && wrapper != null) {
fManager.cancel(wrapper);
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
- }
-
- /**
- *
- */
- public void doneFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
-
- /**
- *
- */
- public void startFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(true);
- }
- }
+ if (fPart != null) {
+ fPart.setCancelEnabled(false);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void doneFetching() {
+ if (fPart != null) {
+ fPart.setCancelEnabled(false);
+ }
+ }
+
+ /**
+ *
+ */
+ public void startFetching() {
+ if (fPart != null) {
+ fPart.setCancelEnabled(true);
+ }
+ }
}
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 c71ef89e7..af4c218b4 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
@@ -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
@@ -20,7 +20,6 @@ import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.model.IWorkbenchAdapter;
-
class CallHierarchyLabelProvider extends AppearanceAwareLabelProvider {
// private final static long FULLY_QUALIFIED = Long.valueOf(ScriptElementLabels.F_FULLY_QUALIFIED | ScriptElementLabels.M_FULLY_QUALIFIED | ScriptElementLabels.I_FULLY_QUALIFIED | ScriptElementLabels.T_FULLY_QUALIFIED ).longValue();
//
@@ -28,66 +27,74 @@ class CallHierarchyLabelProvider extends AppearanceAwareLabelProvider {
// 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.P_COMPRESSED | ScriptElementLabels.APPEND_FILE
| ScriptElementLabels.APPEND_ROOT_PATH;
- private static final int IMAGEFLAGS= DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS;
+ private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS
+ | ScriptElementImageProvider.SMALL_ICONS;
+
+ private ILabelDecorator fDecorator;
- private ILabelDecorator fDecorator;
+ CallHierarchyLabelProvider() {
+ super(TEXTFLAGS, IMAGEFLAGS,
+ DLTKUIPlugin.getDefault().getPreferenceStore());
+ fDecorator = new CallHierarchyLabelDecorator();
+ }
- CallHierarchyLabelProvider() {
- super(TEXTFLAGS, IMAGEFLAGS, DLTKUIPlugin.getDefault().getPreferenceStore());
- fDecorator= new CallHierarchyLabelDecorator();
- }
- @Override
+ @Override
public Image getImage(Object element) {
- Image result= null;
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) element;
-
- if (methodWrapper.getMember() != null) {
- result= fDecorator.decorateImage(super.getImage(methodWrapper.getMember()), methodWrapper);
- }
- } else if (isPendingUpdate(element)) {
- return null;
- } else {
- result= super.getImage(element);
- }
-
- return result;
- }
-
- @Override
+ Image result = null;
+ if (element instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
+
+ if (methodWrapper.getMember() != null) {
+ result = fDecorator.decorateImage(
+ super.getImage(methodWrapper.getMember()),
+ methodWrapper);
+ }
+ } else if (isPendingUpdate(element)) {
+ return null;
+ } else {
+ result = super.getImage(element);
+ }
+
+ return result;
+ }
+
+ @Override
public String getText(Object element) {
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) element;
-
- if (methodWrapper.getMember() != null) {
- return getElementLabel(methodWrapper);
- } else {
- return CallHierarchyMessages.CallHierarchyLabelProvider_root;
- }
- } else if (element == TreeTermination.SEARCH_CANCELED) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_searchCanceled;
- } else if (isPendingUpdate(element)) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_updatePending;
- }
-
- return CallHierarchyMessages.CallHierarchyLabelProvider_noMethodSelected;
- }
-
- private boolean isPendingUpdate(Object element) {
- return element instanceof IWorkbenchAdapter;
- }
- private String getElementLabel(MethodWrapper methodWrapper) {
- String label = super.getText(methodWrapper.getMember());
-
- 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 label;
- }
+ if (element instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
+
+ if (methodWrapper.getMember() != null) {
+ return getElementLabel(methodWrapper);
+ }
+ return CallHierarchyMessages.CallHierarchyLabelProvider_root;
+ } else if (element == TreeTermination.SEARCH_CANCELED) {
+ return CallHierarchyMessages.CallHierarchyLabelProvider_searchCanceled;
+ } else if (isPendingUpdate(element)) {
+ return CallHierarchyMessages.CallHierarchyLabelProvider_updatePending;
+ }
+
+ return CallHierarchyMessages.CallHierarchyLabelProvider_noMethodSelected;
+ }
+
+ private boolean isPendingUpdate(Object element) {
+ return element instanceof IWorkbenchAdapter;
+ }
+
+ private String getElementLabel(MethodWrapper methodWrapper) {
+ String label = super.getText(methodWrapper.getMember());
+
+ 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 label;
+ }
}
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 875c12a35..f7902c348 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
@@ -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
@@ -242,16 +242,16 @@ public class CallHierarchyViewPart extends ViewPart
public MethodWrapper getCurrentMethodWrapper() {
if (fCurrentCallMode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
return fCallerRoot;
- } else {
- return fCalleeRoot;
}
+ return fCalleeRoot;
}
/**
* called from ToggleOrientationAction.
*
* @param orientation
- * VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
+ * VIEW_ORIENTATION_HORIZONTAL or
+ * VIEW_ORIENTATION_VERTICAL
*/
void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
@@ -294,7 +294,7 @@ public class CallHierarchyViewPart extends ViewPart
* called from ToggleCallModeAction.
*
* @param mode
- * CALL_MODE_CALLERS or CALL_MODE_CALLEES
+ * CALL_MODE_CALLERS or CALL_MODE_CALLEES
*/
void setCallMode(int mode) {
if (fCurrentCallMode != mode) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java
index 0a13fea8e..c95cf1bcd 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.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
@@ -14,83 +14,84 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
+class LocationLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+ private static final int COLUMN_ICON = 0;
+ private static final int COLUMN_LINE = 1;
+ private static final int COLUMN_INFO = 2;
-class LocationLabelProvider extends LabelProvider implements ITableLabelProvider {
- private static final int COLUMN_ICON= 0;
- private static final int COLUMN_LINE= 1;
- private static final int COLUMN_INFO= 2;
+ LocationLabelProvider() {
+ // Do nothing
+ }
- LocationLabelProvider() {
- // Do nothing
- }
-
- @Override
+ @Override
public String getText(Object element) {
- return getColumnText(element, COLUMN_INFO);
- }
+ return getColumnText(element, COLUMN_INFO);
+ }
- @Override
+ @Override
public Image getImage(Object element) {
- return getColumnImage(element, COLUMN_ICON);
- }
-
- private String removeWhitespaceOutsideStringLiterals(CallLocation callLocation) {
- StringBuffer buf = new StringBuffer();
- boolean withinString = false;
-
- String s= callLocation.getCallText();
- for (int i = 0; i < s.length(); i++) {
- char ch = s.charAt(i);
-
- if (ch == '"') {
- withinString = !withinString;
- }
-
- if (withinString) {
- buf.append(ch);
- } else if (Character.isWhitespace(ch)) {
- if ((buf.length() == 0) ||
- !Character.isWhitespace(buf.charAt(buf.length() - 1))) {
- if (ch != ' ') {
- ch = ' ';
- }
-
- buf.append(ch);
- }
- } else {
- buf.append(ch);
- }
- }
-
- return buf.toString();
- }
-
- @Override
+ return getColumnImage(element, COLUMN_ICON);
+ }
+
+ private String removeWhitespaceOutsideStringLiterals(
+ CallLocation callLocation) {
+ StringBuffer buf = new StringBuffer();
+ boolean withinString = false;
+
+ String s = callLocation.getCallText();
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+
+ if (ch == '"') {
+ withinString = !withinString;
+ }
+
+ if (withinString) {
+ buf.append(ch);
+ } else if (Character.isWhitespace(ch)) {
+ if ((buf.length() == 0) || !Character
+ .isWhitespace(buf.charAt(buf.length() - 1))) {
+ if (ch != ' ') {
+ ch = ' ';
+ }
+
+ buf.append(ch);
+ }
+ } else {
+ buf.append(ch);
+ }
+ }
+
+ return buf.toString();
+ }
+
+ @Override
public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == COLUMN_ICON) {
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
- }
- return null;
- }
-
- @Override
+ if (columnIndex == COLUMN_ICON) {
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
+ }
+ return null;
+ }
+
+ @Override
public String getColumnText(Object element, int columnIndex) {
- if (element instanceof CallLocation) {
- CallLocation callLocation= (CallLocation) element;
-
- switch (columnIndex) {
- case COLUMN_LINE:
- int lineNumber= callLocation.getLineNumber();
- if (lineNumber == CallLocation.UNKNOWN_LINE_NUMBER) {
- return CallHierarchyMessages.LocationLabelProvider_unknown;
- } else {
- return String.valueOf(lineNumber);
- }
- case COLUMN_INFO:
- return removeWhitespaceOutsideStringLiterals(callLocation);
- }
- }
-
- return ""; //$NON-NLS-1$
- }
+ if (element instanceof CallLocation) {
+ CallLocation callLocation = (CallLocation) element;
+
+ switch (columnIndex) {
+ case COLUMN_LINE:
+ int lineNumber = callLocation.getLineNumber();
+ if (lineNumber == CallLocation.UNKNOWN_LINE_NUMBER) {
+ return CallHierarchyMessages.LocationLabelProvider_unknown;
+ }
+ return String.valueOf(lineNumber);
+ case COLUMN_INFO:
+ return removeWhitespaceOutsideStringLiterals(callLocation);
+ }
+ }
+
+ return ""; //$NON-NLS-1$
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
index 4c401780c..3554cadfc 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.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,14 +16,15 @@ import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.internal.ui.search.DLTKSearchScopeFactory;
import org.eclipse.dltk.ui.DLTKUIPlugin;
-
class SearchScopeHierarchyAction extends SearchScopeAction {
private final SearchScopeActionGroup fGroup;
public SearchScopeHierarchyAction(SearchScopeActionGroup group) {
- super(group, CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
+ super(group,
+ CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
this.fGroup = group;
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
+ setToolTipText(
+ CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
@@ -37,10 +38,10 @@ class SearchScopeHierarchyAction extends SearchScopeAction {
IMethod method = this.fGroup.getView().getMethod();
if (method != null) {
- return SearchEngine.createHierarchyScope(method.getDeclaringType());
- } else {
- return null;
+ return SearchEngine
+ .createHierarchyScope(method.getDeclaringType());
}
+ return null;
} catch (ModelException e) {
DLTKUIPlugin.log(e);
}
@@ -53,11 +54,11 @@ class SearchScopeHierarchyAction extends SearchScopeAction {
return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_HIERARCHY;
}
-
@Override
public String getFullDescription() {
IMethod method = this.fGroup.getView().getMethod();
- return DLTKSearchScopeFactory.getInstance().getHierarchyScopeDescription(method.getDeclaringType());
+ return DLTKSearchScopeFactory.getInstance()
+ .getHierarchyScopeDescription(method.getDeclaringType());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
index 9e9421fad..930b832e6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.dialogs;
@@ -29,9 +28,8 @@ public class StatusUtil {
public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
if (s1.getSeverity() > s2.getSeverity()) {
return s1;
- } else {
- return s2;
}
+ return s2;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java
index a8654dcbe..b19886fb4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.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
@@ -69,25 +69,27 @@ public class TextFieldNavigationHandler {
}
private abstract static class WorkaroundNavigable extends Navigable {
- /* workarounds for:
- * - bug 103630: Add API: Combo#getCaretPosition()
- * - bug 106024: Text#setSelection(int, int) does not handle start > end with SWT.SINGLE
+ /*
+ * workarounds for: - bug 103630: Add API: Combo#getCaretPosition() -
+ * bug 106024: Text#setSelection(int, int) does not handle start > end
+ * with SWT.SINGLE
*/
Point fLastSelection;
int fCaretPosition;
void selectionChanged() {
- Point selection= getSelection();
+ Point selection = getSelection();
if (selection.equals(fLastSelection)) {
// leave caret position
- } else if (selection.x == selection.y) { //empty range
- fCaretPosition= selection.x;
+ } else if (selection.x == selection.y) { // empty range
+ fCaretPosition = selection.x;
} else if (fLastSelection.y == selection.y) {
- fCaretPosition= selection.x; //same end -> assume caret at start
+ fCaretPosition = selection.x; // same end -> assume caret at
+ // start
} else {
- fCaretPosition= selection.y;
+ fCaretPosition = selection.y;
}
- fLastSelection= selection;
+ fLastSelection = selection;
}
}
@@ -106,19 +108,19 @@ public class TextFieldNavigationHandler {
}
private static class TextNavigable extends WorkaroundNavigable {
- static final boolean BUG_106024_TEXT_SELECTION=
- "win32".equals(SWT.getPlatform()) //$NON-NLS-1$
+ static final boolean BUG_106024_TEXT_SELECTION = "win32" //$NON-NLS-1$
+ .equals(SWT.getPlatform())
// on carbon, getCaretPosition() always returns getSelection().x
|| "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
private final Text fText;
public TextNavigable(Text text) {
- fText= text;
+ fText = text;
// workaround for bug 106024:
if (BUG_106024_TEXT_SELECTION) {
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
+ fLastSelection = getSelection();
+ fCaretPosition = fLastSelection.y;
fText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
@@ -159,9 +161,8 @@ public class TextFieldNavigationHandler {
if (BUG_106024_TEXT_SELECTION) {
selectionChanged();
return fCaretPosition;
- } else {
- return fText.getCaretPosition();
}
+ return fText.getCaretPosition();
}
@Override
@@ -174,7 +175,7 @@ public class TextFieldNavigationHandler {
private final StyledText fStyledText;
public StyledTextNavigable(StyledText styledText) {
- fStyledText= styledText;
+ fStyledText = styledText;
}
@Override
@@ -212,10 +213,10 @@ public class TextFieldNavigationHandler {
private final Combo fCombo;
public ComboNavigable(Combo combo) {
- fCombo= combo;
+ fCombo = combo;
// workaround for bug 103630:
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
+ fLastSelection = getSelection();
+ fCaretPosition = fLastSelection.y;
fCombo.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
@@ -265,17 +266,17 @@ public class TextFieldNavigationHandler {
private static class FocusHandler implements FocusListener {
- private static final String EMPTY_TEXT= ""; //$NON-NLS-1$
+ private static final String EMPTY_TEXT = ""; //$NON-NLS-1$
private final DLTKWordIterator fIterator;
private final Navigable fNavigable;
private KeyAdapter fKeyListener;
private FocusHandler(Navigable navigable) {
- fIterator= new DLTKWordIterator();
- fNavigable= navigable;
+ fIterator = new DLTKWordIterator();
+ fNavigable = navigable;
- Control control= navigable.getControl();
+ Control control = navigable.getControl();
control.addFocusListener(this);
if (control.isFocusControl())
activate();
@@ -298,59 +299,79 @@ public class TextFieldNavigationHandler {
private void deactivate() {
if (fKeyListener != null) {
- Control control= fNavigable.getControl();
- if (! control.isDisposed())
+ Control control = fNavigable.getControl();
+ if (!control.isDisposed())
control.removeKeyListener(fKeyListener);
- fKeyListener= null;
+ fKeyListener = null;
}
}
private KeyAdapter getKeyListener() {
if (fKeyListener == null) {
- fKeyListener= new KeyAdapter() {
- private static final String TEXT_EDITOR_CONTEXT_ID= "org.eclipse.ui.textEditorScope"; //$NON-NLS-1$
- private final boolean IS_WORKAROUND= (fNavigable instanceof ComboNavigable)
- || (fNavigable instanceof TextNavigable && TextNavigable.BUG_106024_TEXT_SELECTION);
- private List/*<Submission>*/ fSubmissions;
+ fKeyListener = new KeyAdapter() {
+ private static final String TEXT_EDITOR_CONTEXT_ID = "org.eclipse.ui.textEditorScope"; //$NON-NLS-1$
+ private final boolean IS_WORKAROUND = (fNavigable instanceof ComboNavigable)
+ || (fNavigable instanceof TextNavigable
+ && TextNavigable.BUG_106024_TEXT_SELECTION);
+ private List/* <Submission> */ fSubmissions;
@Override
public void keyPressed(KeyEvent e) {
if (IS_WORKAROUND) {
- if (e.keyCode == SWT.ARROW_LEFT && e.stateMask == SWT.MOD2) {
- int caretPosition= fNavigable.getCaretPosition();
+ if (e.keyCode == SWT.ARROW_LEFT
+ && e.stateMask == SWT.MOD2) {
+ int caretPosition = fNavigable
+ .getCaretPosition();
if (caretPosition != 0) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, caretPosition - 1);
+ fNavigable.setSelection(selection.y,
+ caretPosition - 1);
else
- fNavigable.setSelection(selection.x, caretPosition - 1);
+ fNavigable.setSelection(selection.x,
+ caretPosition - 1);
}
- e.doit= false;
+ e.doit = false;
return;
- } else if (e.keyCode == SWT.ARROW_RIGHT && e.stateMask == SWT.MOD2) {
- String text= fNavigable.getText();
- int caretPosition= fNavigable.getCaretPosition();
+ } else if (e.keyCode == SWT.ARROW_RIGHT
+ && e.stateMask == SWT.MOD2) {
+ String text = fNavigable.getText();
+ int caretPosition = fNavigable
+ .getCaretPosition();
if (caretPosition != text.length()) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, caretPosition + 1);
+ fNavigable.setSelection(selection.x,
+ caretPosition + 1);
else
- fNavigable.setSelection(selection.y, caretPosition + 1);
+ fNavigable.setSelection(selection.y,
+ caretPosition + 1);
}
- e.doit= false;
+ e.doit = false;
return;
}
}
- int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
- KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
+ int accelerator = SWTKeySupport
+ .convertEventToUnmodifiedAccelerator(e);
+ KeySequence keySequence = KeySequence.getInstance(
+ SWTKeySupport.convertAcceleratorToKeyStroke(
+ accelerator));
getSubmissions();
- for (Iterator iter= getSubmissions().iterator(); iter.hasNext();) {
- Submission submission= (Submission) iter.next();
- TriggerSequence[] triggerSequences= submission.getTriggerSequences();
- for (int i= 0; i < triggerSequences.length; i++) {
- if (triggerSequences[i].equals(keySequence)) { // XXX does not work for multi-stroke bindings
- e.doit= false;
+ for (Iterator iter = getSubmissions().iterator(); iter
+ .hasNext();) {
+ Submission submission = (Submission) iter.next();
+ TriggerSequence[] triggerSequences = submission
+ .getTriggerSequences();
+ for (int i = 0; i < triggerSequences.length; i++) {
+ if (triggerSequences[i].equals(keySequence)) { // XXX
+ // does
+ // not
+ // work
+ // for
+ // multi-stroke
+ // bindings
+ e.doit = false;
submission.execute();
return;
}
@@ -358,11 +379,11 @@ public class TextFieldNavigationHandler {
}
}
- private List/*<Submission>*/ getSubmissions() {
+ private List/* <Submission> */ getSubmissions() {
if (fSubmissions != null)
return fSubmissions;
- fSubmissions= new ArrayList();
+ fSubmissions = new ArrayList();
IContextService contextService = PlatformUI
.getWorkbench()
@@ -376,116 +397,151 @@ public class TextFieldNavigationHandler {
IBindingService bindingService = PlatformUI
.getWorkbench()
.getAdapter(IBindingService.class);
- if (contextService == null || commandService == null || handlerService == null || bindingService == null)
+ if (contextService == null || commandService == null
+ || handlerService == null
+ || bindingService == null)
return fSubmissions;
IContextActivation[] contextActivations;
- contextActivations= new IContextActivation[] {
- contextService.activateContext(IContextService.CONTEXT_ID_WINDOW), // XXX relying on workbench feature https://bugs.eclipse.org/bugs/show_bug.cgi?id=115460#c11
- contextService.activateContext(TEXT_EDITOR_CONTEXT_ID)
- };
-
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
+ contextActivations = new IContextActivation[] {
+ contextService.activateContext(
+ IContextService.CONTEXT_ID_WINDOW), // XXX
+ // relying
+ // on
+ // workbench
+ // feature
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=115460#c11
+ contextService.activateContext(
+ TEXT_EDITOR_CONTEXT_ID) };
+
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .following(caretPosition);
if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, newCaret);
+ fNavigable.setSelection(selection.x,
+ newCaret);
else
- fNavigable.setSelection(selection.y, newCaret);
+ fNavigable.setSelection(selection.y,
+ newCaret);
}
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .preceding(caretPosition);
if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, newCaret);
+ fNavigable.setSelection(selection.y,
+ newCaret);
else
- fNavigable.setSelection(selection.x, newCaret);
+ fNavigable.setSelection(selection.x,
+ newCaret);
}
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.WORD_NEXT)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.WORD_NEXT)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .following(caretPosition);
if (newCaret != BreakIterator.DONE)
fNavigable.setSelection(newCaret, newCaret);
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .preceding(caretPosition);
if (newCaret != BreakIterator.DONE)
fNavigable.setSelection(newCaret, newCaret);
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
@Override
public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
+ Point selection = fNavigable.getSelection();
+ String text = fNavigable.getText();
int start;
int end;
if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
+ start = selection.x;
+ end = selection.y;
} else {
fIterator.setText(text);
- start= fNavigable.getCaretPosition();
- end= fIterator.following(start);
+ start = fNavigable.getCaretPosition();
+ end = fIterator.following(start);
fIterator.setText(EMPTY_TEXT);
if (end == BreakIterator.DONE)
return;
}
- fNavigable.setText(text.substring(0, start) + text.substring(end));
+ fNavigable.setText(text.substring(0, start)
+ + text.substring(end));
fNavigable.setSelection(start, start);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
@Override
public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
+ Point selection = fNavigable.getSelection();
+ String text = fNavigable.getText();
int start;
int end;
if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
+ start = selection.x;
+ end = selection.y;
} else {
fIterator.setText(text);
- end= fNavigable.getCaretPosition();
- start= fIterator.preceding(end);
+ end = fNavigable.getCaretPosition();
+ start = fIterator.preceding(end);
fIterator.setText(EMPTY_TEXT);
if (start == BreakIterator.DONE)
return;
}
- fNavigable.setText(text.substring(0, start) + text.substring(end));
+ fNavigable.setText(text.substring(0, start)
+ + text.substring(end));
fNavigable.setSelection(start, start);
}
});
- for (int i= 0; i < contextActivations.length; i++) {
- contextService.deactivateContext(contextActivations[i]);
+ for (int i = 0; i < contextActivations.length; i++) {
+ contextService
+ .deactivateContext(contextActivations[i]);
}
return fSubmissions;
@@ -501,7 +557,7 @@ public class TextFieldNavigationHandler {
private TriggerSequence[] fTriggerSequences;
public Submission(TriggerSequence[] triggerSequences) {
- fTriggerSequences= triggerSequences;
+ fTriggerSequences = triggerSequences;
}
public TriggerSequence[] getTriggerSequences() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java
index 472cab92e..aa28f784d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.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
@@ -32,10 +32,11 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Creates a new delegating drop adapter.
*
- * @param listeners an array of potential listeners
+ * @param listeners
+ * an array of potential listeners
*/
public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
- fListeners= listeners;
+ fListeners = listeners;
}
/**
@@ -43,12 +44,13 @@ public class DelegatingDropAdapter implements DropTargetListener {
* is updated, and <code>#dragEnter()</code> is forwarded to the current
* listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragEnter(DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
- fOriginalDropType= event.detail;
+ fOriginalDropType = event.detail;
updateCurrentListener(event);
}
@@ -56,7 +58,8 @@ public class DelegatingDropAdapter implements DropTargetListener {
* The cursor has left the drop target boundaries. The event is forwarded to
* the current listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragLeave(DropTargetEvent)
*/
@Override
@@ -69,15 +72,16 @@ public class DelegatingDropAdapter implements DropTargetListener {
* changing a drag modifier key while dragging). Updates the current
* listener and forwards this event to that listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragOperationChanged(DropTargetEvent)
*/
@Override
public void dragOperationChanged(final DropTargetEvent event) {
- fOriginalDropType= event.detail;
- TransferDropTargetListener oldListener= getCurrentListener();
+ fOriginalDropType = event.detail;
+ TransferDropTargetListener oldListener = getCurrentListener();
updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
+ final TransferDropTargetListener newListener = getCurrentListener();
// only notify the current listener if it hasn't changed based on the
// operation change. otherwise the new listener would get a dragEnter
// followed by a dragOperationChanged with the exact same event.
@@ -97,14 +101,15 @@ public class DelegatingDropAdapter implements DropTargetListener {
* drag operation the <code>event.detail</code> field is set to
* <code>DND.DROP_NONE</code> to indicate an invalid drop.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragOver(DropTargetEvent)
*/
@Override
public void dragOver(final DropTargetEvent event) {
- TransferDropTargetListener oldListener= getCurrentListener();
+ TransferDropTargetListener oldListener = getCurrentListener();
updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
+ final TransferDropTargetListener newListener = getCurrentListener();
// only notify the current listener if it hasn't changed based on the
// drag over. otherwise the new listener would get a dragEnter
@@ -123,7 +128,8 @@ public class DelegatingDropAdapter implements DropTargetListener {
* Forwards this event to the current listener, if there is one. Sets the
* current listener to <code>null</code> afterwards.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#drop(DropTargetEvent)
*/
@Override
@@ -143,7 +149,8 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Forwards this event to the current listener if there is one.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dropAccept(DropTargetEvent)
*/
@Override
@@ -173,14 +180,17 @@ public class DelegatingDropAdapter implements DropTargetListener {
* <code>null</code> if the listener does not support any of the specified
* data types.
*
- * @param dataTypes available data types
- * @param listener <code>TransferDropTargetListener</code> to use for
- * testing supported data types.
+ * @param dataTypes
+ * available data types
+ * @param listener
+ * <code>TransferDropTargetListener</code> to use for
+ * testing supported data types.
* @return the transfer data type supported by the given listener or
* <code>null</code>.
*/
- private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
- for (int i= 0; i < dataTypes.length; i++) {
+ private TransferData getSupportedTransferType(TransferData[] dataTypes,
+ TransferDropTargetListener listener) {
+ for (int i = 0; i < dataTypes.length; i++) {
if (listener.getTransfer().isSupportedType(dataTypes[i])) {
return dataTypes[i];
}
@@ -195,9 +205,9 @@ public class DelegatingDropAdapter implements DropTargetListener {
* @return the combined set of <code>Transfer</code> types
*/
public Transfer[] getTransfers() {
- Transfer[] types= new Transfer[fListeners.length];
- for (int i= 0; i < fListeners.length; i++) {
- types[i]= fListeners[i].getTransfer();
+ Transfer[] types = new Transfer[fListeners.length];
+ for (int i = 0; i < fListeners.length; i++) {
+ types[i] = fListeners[i].getTransfer();
}
return types;
}
@@ -209,7 +219,8 @@ public class DelegatingDropAdapter implements DropTargetListener {
* @return <code>true</code> if the new listener is different than the
* previous <code>false</code> otherwise
*/
- private boolean setCurrentListener(TransferDropTargetListener listener, final DropTargetEvent event) {
+ private boolean setCurrentListener(TransferDropTargetListener listener,
+ final DropTargetEvent event) {
if (fCurrentListener == listener)
return false;
if (fCurrentListener != null) {
@@ -220,7 +231,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
}
});
}
- fCurrentListener= listener;
+ fCurrentListener = listener;
if (fCurrentListener != null) {
SafeRunner.run(new SafeRunnable() {
@Override
@@ -235,42 +246,43 @@ public class DelegatingDropAdapter implements DropTargetListener {
/**
* Updates the current listener to one that can handle the drop. There can
* be many listeners and each listener may be able to handle many
- * <code>TransferData</code> types. The first listener found that can
- * handle a drop of one of the given <code>TransferData</code> types will
- * be selected. If no listener can handle the drag operation the
- * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code>
- * to indicate an invalid drop.
+ * <code>TransferData</code> types. The first listener found that can handle
+ * a drop of one of the given <code>TransferData</code> types will be
+ * selected. If no listener can handle the drag operation the
+ * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code> to
+ * indicate an invalid drop.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
*/
private void updateCurrentListener(DropTargetEvent event) {
- int originalDetail= event.detail;
+ int originalDetail = event.detail;
// Revert the detail to the "original" drop type that the User
// indicated. This is necessary because the previous listener
// may have changed the detail to something other than what the
// user indicated.
- event.detail= fOriginalDropType;
+ event.detail = fOriginalDropType;
- for (int i= 0; i < fListeners.length; i++) {
- TransferDropTargetListener listener= fListeners[i];
- TransferData dataType= getSupportedTransferType(event.dataTypes, listener);
+ for (int i = 0; i < fListeners.length; i++) {
+ TransferDropTargetListener listener = fListeners[i];
+ TransferData dataType = getSupportedTransferType(event.dataTypes,
+ listener);
if (dataType != null) {
- TransferData originalDataType= event.currentDataType;
+ TransferData originalDataType = event.currentDataType;
// set the data type supported by the drop listener
- event.currentDataType= dataType;
+ event.currentDataType = dataType;
if (listener.isEnabled(event)) {
// if the listener stays the same, set its previously
// determined
// event detail
if (!setCurrentListener(listener, event))
- event.detail= originalDetail;
+ event.detail = originalDetail;
return;
- } else {
- event.currentDataType= originalDataType;
}
+ event.currentDataType = originalDataType;
}
}
setCurrentListener(null, event);
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java
index 17307e730..79dc130ae 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.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
@@ -215,8 +215,8 @@ public abstract class BracketInserter
* @param offset
* @param partitioning
* @param contentTypes
- * acceptable content types, if empty only
- * IDocument.DEFAULT_CONTENT_TYPE is checked.
+ * acceptable content types, if empty only
+ * IDocument.DEFAULT_CONTENT_TYPE is checked.
* @return
* @throws BadLocationException
* @since 2.0
@@ -232,8 +232,7 @@ public abstract class BracketInserter
return true;
}
return false;
- } else {
- return IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
}
+ return IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
index ded861f6e..5ab24f0f7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
@@ -1694,12 +1694,12 @@ public abstract class ScriptEditor extends AbstractDecoratedTextEditor
// int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
// return new DefaultInformationControl(shell, SWT.RESIZE
// | SWT.TOOL, style, new HTMLTextPresenter(cutDown));
- if (BrowserInformationControl.isAvailable(shell))
+ if (BrowserInformationControl.isAvailable(shell)) {
return new BrowserInformationControl(shell,
JFaceResources.DIALOG_FONT, true);
- else
- return new DefaultInformationControl(shell,
- new HTMLTextPresenter(cutDown));
+ }
+ return new DefaultInformationControl(shell,
+ new HTMLTextPresenter(cutDown));
};
fInformationPresenter = new InformationPresenter(
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java
index bf3537c3d..141639557 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.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
@@ -198,10 +198,10 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
Annotation annotation = new Annotation(annotationType, false, null);
AnnotationPreference preference = lookup
.getAnnotationPreference(annotation);
- if (preference != null)
+ if (preference != null) {
return preference.getPresentationLayer() + 1;
- else
- return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
+ }
+ return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
private static Image fgQuickFixImage;
@@ -578,12 +578,11 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
private boolean isScriptMarker(IMarker marker) {
if (problemFactory != null) {
return problemFactory.isValidMarker(marker);
- } else {
- return MarkerUtilities.isMarkerType(marker,
- DefaultProblem.MARKER_TYPE_PROBLEM)
- || MarkerUtilities.isMarkerType(marker,
- DefaultProblem.MARKER_TYPE_TASK);
}
+ return MarkerUtilities.isMarkerType(marker,
+ DefaultProblem.MARKER_TYPE_PROBLEM)
+ || MarkerUtilities.isMarkerType(marker,
+ DefaultProblem.MARKER_TYPE_TASK);
}
@Override
@@ -632,8 +631,9 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* Sets up the infrastructure necessary for problem reporting.
*
* @param insideReportingSequence
- * <code>true</code> if this method call is issued from
- * inside a reporting sequence
+ * <code>true</code> if this method
+ * call is issued from inside a
+ * reporting sequence
*/
private void internalBeginReporting(boolean insideReportingSequence) {
@@ -950,7 +950,7 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* Updates this model to the given marker deltas.
*
* @param markerDeltas
- * the array of marker deltas
+ * the array of marker deltas
*/
@Override
protected void update(IMarkerDelta[] markerDeltas) {
@@ -1150,7 +1150,7 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* Creates a source module from the given file.
*
* @param file
- * the file from which to create the source module
+ * the file from which to create the source module
*/
protected ISourceModule createSourceModule(IFile file) {
@@ -1306,9 +1306,10 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* monitor.
*
* @param monitor
- * the parent progress monitor
+ * the parent progress monitor
* @param ticks
- * the number of work ticks allocated from the parent monitor
+ * the number of work ticks allocated from the parent
+ * monitor
* @return the new sub-progress monitor
*/
private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor,
@@ -1358,10 +1359,6 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
overwrite);
}
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.
- * DocumentProviderOperation#getSchedulingRule()
- */
@Override
public ISchedulingRule getSchedulingRule() {
@@ -1369,8 +1366,8 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
IFile file = ((IFileEditorInput) info.fElement)
.getFile();
return computeSchedulingRule(file);
- } else
- return null;
+ }
+ return null;
}
};
}
@@ -1396,8 +1393,7 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
Assert.isTrue(resource instanceof IFile);
- isSynchronized = resource
- .isSynchronized(IResource.DEPTH_ZERO);
+ isSynchronized = resource.isSynchronized(IResource.DEPTH_ZERO);
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=98327 Make sure
* file gets save in commit() if the underlying file has been
@@ -1410,8 +1406,7 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
// underlying resource has been deleted, just recreate
// file,
// ignore the rest
- createFileFromDocument(monitor, (IFile) resource,
- document);
+ createFileFromDocument(monitor, (IFile) resource, document);
return;
}
@@ -1604,9 +1599,10 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* Creates a fake compilation unit.
*
* @param element
- * the element
+ * the element
* @param setContents
- * tells whether to read and set the contents to the new CU
+ * tells whether to read and set the contents to the
+ * new CU
*
*/
private ISourceModule createFakeSourceModule(Object element,
@@ -1780,7 +1776,7 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* path.
*
* @param path
- * the path to match
+ * the path to match
* @return the matching script project or <code>null</code>
*
*/
@@ -1831,15 +1827,15 @@ public class SourceModuleDocumentProvider extends TextFileDocumentProvider
* </p>
*
* @param info
- * compilation unit info
+ * compilation unit info
* @param changedRegions
- * the array with the changed regions
+ * the array with the changed regions
* @param listeners
- * the listeners to notify
+ * the listeners to notify
* @param monitor
- * the progress monitor
+ * the progress monitor
* @throws CoreException
- * if something goes wrong
+ * if something goes wrong
* @see IPostSaveListener
* @since 3.0
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java
index 703361e7a..a0dfca074 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.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
@@ -105,12 +105,12 @@ public class GoToNextPreviousMemberAction extends Action implements IUpdate {
Integer oldOffset = Integer.valueOf(oldSourceRange.getOffset());
int index = Arrays.binarySearch(offsetArray, oldOffset);
- if (fIsGotoNext)
+ if (fIsGotoNext) {
return createNewSourceRange(
getNextOffset(index, offsetArray, oldOffset));
- else
- return createNewSourceRange(
- getPreviousOffset(index, offsetArray, oldOffset));
+ }
+ return createNewSourceRange(
+ getPreviousOffset(index, offsetArray, oldOffset));
} catch (ModelException e) {
DLTKUIPlugin.log(e); // dialog would be too heavy here
@@ -137,10 +137,10 @@ public class GoToNextPreviousMemberAction extends Action implements IUpdate {
return offsetArray[0];
if (index == 0) {
- if (offsetArray.length != 1)
+ if (offsetArray.length != 1) {
return offsetArray[1];
- else
- return offsetArray[0];
+ }
+ return offsetArray[0];
}
if (index > 0) {
if (index == offsetArray.length - 1)
@@ -149,10 +149,10 @@ public class GoToNextPreviousMemberAction extends Action implements IUpdate {
}
Assert.isTrue(index < -1);
int absIndex = Math.abs(index);
- if (absIndex > offsetArray.length)
+ if (absIndex > offsetArray.length) {
return oldOffset;
- else
- return offsetArray[absIndex - 1];
+ }
+ return offsetArray[absIndex - 1];
}
private static ISourceRange createNewSourceRange(Integer offset) {
@@ -199,7 +199,8 @@ public class GoToNextPreviousMemberAction extends Action implements IUpdate {
}
private static void addOffset(List result, int offset) {
- if (offset >= 0)
+ if (offset >= 0) {
result.add(Integer.valueOf(offset));
+ }
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java
index c758cd0ec..56b328cc4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.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
@@ -108,10 +108,10 @@ public class SemanticHighlightingReconciler
return;
// ensure at most one thread can be reconciling at any time
synchronized (fReconcileLock) {
- if (fIsReconciling)
+ if (fIsReconciling) {
return;
- else
- fIsReconciling = true;
+ }
+ fIsReconciling = true;
}
fJobPresenter = fPresenter;
fJobSemanticHighlightings = fSemanticHighlightings;
@@ -165,11 +165,11 @@ public class SemanticHighlightingReconciler
* Update the presentation.
*
* @param textPresentation
- * the text presentation
+ * the text presentation
* @param addedPositions
- * the added positions
+ * the added positions
* @param removedPositions
- * the removed positions
+ * the removed positions
*/
private void updatePresentation(TextPresentation textPresentation,
HighlightedPosition[] addedPositions,
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java
index aad983621..44f4bb935 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.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
@@ -288,10 +288,10 @@ public class CustomFiltersDialog extends SelectionDialog {
@Override
public String getText(Object element) {
- if (element instanceof FilterDescriptor)
+ if (element instanceof FilterDescriptor) {
return ((FilterDescriptor) element).getName();
- else
- return null;
+ }
+ return null;
}
};
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java
index d64d55d7d..68bf3edda 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.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
@@ -148,12 +148,12 @@ public class FilterDescriptor implements Comparable, IPluginContribution {
public String getId() {
if (isPatternFilter()) {
String targetId = getTargetId();
- if (targetId == null)
+ if (targetId == null) {
return PATTERN_FILTER_ID_PREFIX + getPattern();
- else
- return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
- } else
- return fElement.getAttribute(ID_ATTRIBUTE);
+ }
+ return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
+ }
+ return fElement.getAttribute(ID_ATTRIBUTE);
}
/**
@@ -242,11 +242,11 @@ public class FilterDescriptor implements Comparable, IPluginContribution {
*/
@Override
public int compareTo(Object o) {
- if (o instanceof FilterDescriptor)
+ if (o instanceof FilterDescriptor) {
return Collator.getInstance().compare(getName(),
((FilterDescriptor) o).getName());
- else
- return Integer.MIN_VALUE;
+ }
+ return Integer.MIN_VALUE;
}
// ---- initialization ---------------------------------------------------
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java
index b834dc3a9..13374e609 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.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,10 +23,10 @@ public class NoPackageContainingFoldersFilter extends ViewerFilter {
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof IFolder) {
try {
- if (containsPackage((IFolder)element))
+ if (containsPackage((IFolder) element)) {
return true;
- else
- return false;
+ }
+ return false;
} catch (CoreException e) {
return true;
}
@@ -36,12 +36,13 @@ public class NoPackageContainingFoldersFilter extends ViewerFilter {
}
private boolean containsPackage(IFolder folder) throws CoreException {
- IModelElement element= DLTKCore.create(folder);
+ IModelElement element = DLTKCore.create(folder);
if (element instanceof IScriptFolder)
return true;
- IResource[] resources= folder.members();
- for (int i= 0; i < resources.length; i++) {
- if (resources[i] instanceof IFolder && containsPackage((IFolder)resources[i]))
+ IResource[] resources = folder.members();
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i] instanceof IFolder
+ && containsPackage((IFolder) resources[i]))
return true;
}
return false;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java
index 1277e7d5d..51aba3da4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.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
@@ -252,21 +252,18 @@ public class ProjectFragmentProvider implements IPropertyChangeListener {
IProjectFragment root = (IProjectFragment) parent;
if (root.isArchive()) {
return findNextLevelParentByElementName(fragment);
- } else {
-
- IResource resource = fragment.getUnderlyingResource();
- if ((resource != null)
- && (resource instanceof IFolder)) {
- IFolder folder = (IFolder) resource;
- IResource res = folder.getParent();
-
- IModelElement el = DLTKCore.create(res);
- if (el != null) {
- return el;
- } else {
- return res;
- }
+ }
+
+ IResource resource = fragment.getUnderlyingResource();
+ if ((resource != null) && (resource instanceof IFolder)) {
+ IFolder folder = (IFolder) resource;
+ IResource res = folder.getParent();
+
+ IModelElement el = DLTKCore.create(res);
+ if (el != null) {
+ return el;
}
+ return res;
}
return parent;
}
@@ -415,10 +412,10 @@ public class ProjectFragmentProvider implements IPropertyChangeListener {
Object parent = findNextLevelParentByElementName(element);
if (parent instanceof IProjectFragment) {
IProjectFragment root = (IProjectFragment) parent;
- if (isRootProject(root))
+ if (isRootProject(root)) {
return root.getScriptProject();
- else
- return root;
+ }
+ return root;
}
Object grandParent = getParent(parent);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
index 8480dce74..37f4debc4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.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
@@ -89,7 +89,8 @@ public class ScriptExplorerContentProvider
* Creates a new content provider for Java elements.
*
* @param provideMembers
- * if set, members of compilation units and class files are shown
+ * if set, members of compilation units and class
+ * files are shown
*/
public ScriptExplorerContentProvider(final boolean provideMembers) {
super(provideMembers);
@@ -472,12 +473,12 @@ public class ScriptExplorerContentProvider
* Returns the hierarchical packages inside a given fragment or root.
*
* @param parent
- * The parent package fragment root
+ * The parent package fragment root
* @param fragment
- * The package to get the children for or 'null' to get the
- * children of the root.
+ * The package to get the children for or 'null' to get
+ * the children of the root.
* @param result
- * Collection where the resulting elements are added
+ * Collection where the resulting elements are added
* @throws JavaModelException
*/
private void getHierarchicalPackageChildren(final IProjectFragment parent,
@@ -535,11 +536,11 @@ public class ScriptExplorerContentProvider
* Returns the hierarchical packages inside a given folder.
*
* @param folder
- * The parent folder
+ * The parent folder
* @param result
- * Collection where the resulting elements are added
+ * Collection where the resulting elements are added
* @throws CoreException
- * thrown when elements could not be accessed
+ * thrown when elements could not be accessed
*/
private void getHierarchicalPackagesInFolder(final IFolder folder,
final Collection<Object> result) throws CoreException {
@@ -644,14 +645,15 @@ public class ScriptExplorerContentProvider
* the tree is fully refreshed starting at this node.
*
* @param delta
- * the delta to process
+ * the delta to process
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
* @return true is returned if the conclusion is to refresh a parent of an
* element. In that case no siblings need to be processed
* @throws JavaModelException
- * thrown when the access to an element failed
+ * thrown when the access to an element
+ * failed
*/
private boolean processDelta(final IModelElementDelta delta,
final Collection<Runnable> runnables) throws ModelException {
@@ -696,11 +698,10 @@ public class ScriptExplorerContentProvider
if (parent instanceof IProjectFragment) {
postRemove(element, runnables);
return false;
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT,
- element, runnables);
- return true;
}
+ postRefresh(internalGetParent(parent), GRANT_PARENT,
+ element, runnables);
+ return true;
} else if (kind == IModelElementDelta.ADDED) {
final Object parent = getHierarchicalPackageParent(
(IScriptFolder) element);
@@ -708,15 +709,13 @@ public class ScriptExplorerContentProvider
if (fFoldPackages) {
postRefresh(parent, PARENT, element, runnables);
return true;
- } else {
- postAdd(parent, element, runnables);
- return false;
}
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT,
- element, runnables);
- return true;
+ postAdd(parent, element, runnables);
+ return false;
}
+ postRefresh(internalGetParent(parent), GRANT_PARENT,
+ element, runnables);
+ return true;
}
handleAffectedChildren(delta, element, runnables);
return false;
@@ -824,9 +823,8 @@ public class ScriptExplorerContentProvider
}
}
return true;
- } else {
- postAdd(parent, element, runnables);
}
+ postAdd(parent, element, runnables);
}
if (elementType == IModelElement.SOURCE_MODULE
@@ -962,10 +960,10 @@ public class ScriptExplorerContentProvider
* Updates the package icon
*
* @param element
- * the element to update
+ * the element to update
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
*/
private void postUpdateIcon(final IModelElement element,
final Collection<Runnable> runnables) {
@@ -977,12 +975,12 @@ public class ScriptExplorerContentProvider
* Process a resource delta.
*
* @param delta
- * the delta to process
+ * the delta to process
* @param parent
- * the parent
+ * the parent
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
* @return true if the parent got refreshed
*/
private boolean processResourceDelta(final IResourceDelta delta,
@@ -1006,10 +1004,9 @@ public class ScriptExplorerContentProvider
ScriptExplorerContentProvider.PARENT, parent,
runnables);
return true;
- } else {
- postRemove(resource, runnables);
- return false;
}
+ postRemove(resource, runnables);
+ return false;
}
if ((status & IResourceDelta.ADDED) != 0) {
if (parent instanceof IScriptFolder) {
@@ -1019,10 +1016,9 @@ public class ScriptExplorerContentProvider
ScriptExplorerContentProvider.PARENT, parent,
runnables);
return true;
- } else {
- postAdd(parent, resource, runnables);
- return false;
}
+ postAdd(parent, resource, runnables);
+ return false;
}
if ((status & IResourceDelta.CHANGED) != 0) {
if ((flags & IResourceDelta.TYPE) != 0) {
@@ -1085,12 +1081,13 @@ public class ScriptExplorerContentProvider
* Can be implemented by subclasses to add additional elements to refresh
*
* @param toRefresh
- * the elements to refresh
+ * the elements to refresh
* @param relation
- * the relation to the affected element ({@link #GRANT_PARENT},
- * {@link #PARENT}, {@link #ORIGINAL}, {@link #PROJECT})
+ * the relation to the affected element
+ * ({@link #GRANT_PARENT}, {@link #PARENT},
+ * {@link #ORIGINAL}, {@link #PROJECT})
* @param affectedElement
- * the affected element
+ * the affected element
*/
protected void augmentElementToRefresh(final List<Object> toRefresh,
final int relation, final Object affectedElement) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java
index 532a8136d..d5a4219fd 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.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
@@ -15,390 +15,404 @@ import org.eclipse.jface.viewers.IElementComparer;
/**
* CustomHashtable associates keys with values. Keys and values cannot be null.
- * The size of the Hashtable is the number of key/value pairs it contains.
- * The capacity is the number of key/value pairs the Hashtable can hold.
- * The load factor is a float value which determines how full the Hashtable
- * gets before expanding the capacity. If the load factor of the Hashtable
- * is exceeded, the capacity is doubled.
+ * The size of the Hashtable is the number of key/value pairs it contains. The
+ * capacity is the number of key/value pairs the Hashtable can hold. The load
+ * factor is a float value which determines how full the Hashtable gets before
+ * expanding the capacity. If the load factor of the Hashtable is exceeded, the
+ * capacity is doubled.
* <p>
* CustomHashtable allows a custom comparator and hash code provider.
*/
/* package */final class CustomHashtable {
- /**
- * HashMapEntry is an internal class which is used to hold the entries of a Hashtable.
- */
- private static class HashMapEntry {
- Object key, value;
+ /**
+ * HashMapEntry is an internal class which is used to hold the entries of a
+ * Hashtable.
+ */
+ private static class HashMapEntry {
+ Object key, value;
- HashMapEntry next;
+ HashMapEntry next;
- HashMapEntry(Object theKey, Object theValue) {
- key = theKey;
- value = theValue;
- }
- }
+ HashMapEntry(Object theKey, Object theValue) {
+ key = theKey;
+ value = theValue;
+ }
+ }
- private static final class EmptyEnumerator implements Enumeration {
- @Override
+ private static final class EmptyEnumerator implements Enumeration {
+ @Override
public boolean hasMoreElements() {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public Object nextElement() {
- throw new NoSuchElementException();
- }
- }
+ throw new NoSuchElementException();
+ }
+ }
- private class HashEnumerator implements Enumeration {
- boolean key;
+ private class HashEnumerator implements Enumeration {
+ boolean key;
- int start;
+ int start;
- HashMapEntry entry;
+ HashMapEntry entry;
- HashEnumerator(boolean isKey) {
- key = isKey;
- start = firstSlot;
- }
+ HashEnumerator(boolean isKey) {
+ key = isKey;
+ start = firstSlot;
+ }
- @Override
+ @Override
public boolean hasMoreElements() {
- if (entry != null)
- return true;
- while (start <= lastSlot)
- if (elementData[start++] != null) {
- entry = elementData[start - 1];
- return true;
- }
- return false;
- }
-
- @Override
+ if (entry != null)
+ return true;
+ while (start <= lastSlot)
+ if (elementData[start++] != null) {
+ entry = elementData[start - 1];
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public Object nextElement() {
- if (hasMoreElements()) {
- Object result = key ? entry.key : entry.value;
- entry = entry.next;
- return result;
- } else
- throw new NoSuchElementException();
- }
- }
-
- transient int elementCount;
-
- transient HashMapEntry[] elementData;
-
- private float loadFactor;
-
- private int threshold;
-
- transient int firstSlot = 0;
-
- transient int lastSlot = -1;
-
- transient private IElementComparer comparer;
-
- private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
-
- /**
- * The default capacity used when not specified in the constructor.
- */
- public static final int DEFAULT_CAPACITY = 13;
-
- /**
- * Constructs a new Hashtable using the default capacity
- * and load factor.
- */
- public CustomHashtable() {
- this(13);
- }
-
- /**
- * Constructs a new Hashtable using the specified capacity
- * and the default load factor.
- *
- * @param capacity the initial capacity
- */
- public CustomHashtable(int capacity) {
- this(capacity, null);
- }
-
- /**
- * Constructs a new hash table with the default capacity and the given
- * element comparer.
- *
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(IElementComparer comparer) {
- this(DEFAULT_CAPACITY, comparer);
- }
-
- /**
- * Constructs a new hash table with the given capacity and the given
- * element comparer.
- *
- * @param capacity the maximum number of elements that can be added without
- * rehashing
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(int capacity, IElementComparer comparer) {
- if (capacity >= 0) {
- elementCount = 0;
- elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
- firstSlot = elementData.length;
- loadFactor = 0.75f;
- computeMaxSize();
- } else
- throw new IllegalArgumentException();
- this.comparer = comparer;
- }
-
- /**
- * Constructs a new hash table with enough capacity to hold all keys in the
- * given hash table, then adds all key/value pairs in the given hash table
- * to the new one, using the given element comparer.
- *
- * @param table the hash table to add from
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
- this(table.size() * 2, comparer);
- for (int i = table.elementData.length; --i >= 0;) {
- HashMapEntry entry = table.elementData[i];
- while (entry != null) {
- put(entry.key, entry.value);
- entry = entry.next;
- }
- }
- }
-
- private void computeMaxSize() {
- threshold = (int) (elementData.length * loadFactor);
- }
-
- /**
- * Answers if this Hashtable contains the specified object as a key
- * of one of the key/value pairs.
- *
- * @param key the object to look for as a key in this Hashtable
- * @return true if object is a key in this Hashtable, false otherwise
- */
- public boolean containsKey(Object key) {
- return getEntry(key) != null;
- }
-
- /**
- * Answers an Enumeration on the values of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the values of this Hashtable
- */
- public Enumeration elements() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(false);
- }
-
- /**
- * Answers the value associated with the specified key in
- * this Hashtable.
- *
- * @param key the key of the value returned
- * @return the value associated with the specified key, null if the specified key
- * does not exist
- */
- public Object get(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry.value;
- entry = entry.next;
- }
- return null;
- }
-
- private HashMapEntry getEntry(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry;
- entry = entry.next;
- }
- return null;
- }
-
- /**
- * Answers the hash code for the given key.
- */
- private int hashCode(Object key) {
- if (comparer == null)
- return key.hashCode();
- else
- return comparer.hashCode(key);
- }
-
- /**
- * Compares two keys for equality.
- */
- private boolean keyEquals(Object a, Object b) {
- if (comparer == null)
- return a.equals(b);
- else
- return comparer.equals(a, b);
- }
-
- /**
- * Answers an Enumeration on the keys of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the keys of this Hashtable
- */
- public Enumeration keys() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(true);
- }
-
- /**
- * Associate the specified value with the specified key in this Hashtable.
- * If the key already exists, the old value is replaced. The key and value
- * cannot be null.
- *
- * @param key the key to add
- * @param value the value to add
- * @return the old value associated with the specified key, null if the key did
- * not exist
- */
- public Object put(Object key, Object value) {
- if (key != null && value != null) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key))
- entry = entry.next;
- if (entry == null) {
- if (++elementCount > threshold) {
- rehash();
- index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- }
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- entry = new HashMapEntry(key, value);
- entry.next = elementData[index];
- elementData[index] = entry;
- return null;
- }
- Object result = entry.value;
- entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607
- entry.value = value;
- return result;
- } else
- throw new NullPointerException();
- }
-
- /**
- * Increases the capacity of this Hashtable. This method is sent when
- * the size of this Hashtable exceeds the load factor.
- */
- private void rehash() {
- int length = elementData.length << 1;
- if (length == 0)
- length = 1;
- firstSlot = length;
- lastSlot = -1;
- HashMapEntry[] newData = new HashMapEntry[length];
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- HashMapEntry next = entry.next;
- entry.next = newData[index];
- newData[index] = entry;
- entry = next;
- }
- }
- elementData = newData;
- computeMaxSize();
- }
-
- /**
- * Remove the key/value pair with the specified key from this Hashtable.
- *
- * @param key the key to remove
- * @return the value associated with the specified key, null if the specified key
- * did not exist
- */
- public Object remove(Object key) {
- HashMapEntry last = null;
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key)) {
- last = entry;
- entry = entry.next;
- }
- if (entry != null) {
- if (last == null)
- elementData[index] = entry.next;
- else
- last.next = entry.next;
- elementCount--;
- return entry.value;
- }
- return null;
- }
-
- /**
- * Answers the number of key/value pairs in this Hashtable.
- *
- * @return the number of key/value pairs in this Hashtable
- */
- public int size() {
- return elementCount;
- }
-
- /**
- * Answers the string representation of this Hashtable.
- *
- * @return the string representation of this Hashtable
- */
- @Override
+ if (hasMoreElements()) {
+ Object result = key ? entry.key : entry.value;
+ entry = entry.next;
+ return result;
+ }
+ throw new NoSuchElementException();
+ }
+ }
+
+ transient int elementCount;
+
+ transient HashMapEntry[] elementData;
+
+ private float loadFactor;
+
+ private int threshold;
+
+ transient int firstSlot = 0;
+
+ transient int lastSlot = -1;
+
+ transient private IElementComparer comparer;
+
+ private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
+
+ /**
+ * The default capacity used when not specified in the constructor.
+ */
+ public static final int DEFAULT_CAPACITY = 13;
+
+ /**
+ * Constructs a new Hashtable using the default capacity and load factor.
+ */
+ public CustomHashtable() {
+ this(13);
+ }
+
+ /**
+ * Constructs a new Hashtable using the specified capacity and the default
+ * load factor.
+ *
+ * @param capacity
+ * the initial capacity
+ */
+ public CustomHashtable(int capacity) {
+ this(capacity, null);
+ }
+
+ /**
+ * Constructs a new hash table with the default capacity and the given
+ * element comparer.
+ *
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(IElementComparer comparer) {
+ this(DEFAULT_CAPACITY, comparer);
+ }
+
+ /**
+ * Constructs a new hash table with the given capacity and the given element
+ * comparer.
+ *
+ * @param capacity
+ * the maximum number of elements that can be added
+ * without rehashing
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(int capacity, IElementComparer comparer) {
+ if (capacity >= 0) {
+ elementCount = 0;
+ elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
+ firstSlot = elementData.length;
+ loadFactor = 0.75f;
+ computeMaxSize();
+ } else
+ throw new IllegalArgumentException();
+ this.comparer = comparer;
+ }
+
+ /**
+ * Constructs a new hash table with enough capacity to hold all keys in the
+ * given hash table, then adds all key/value pairs in the given hash table
+ * to the new one, using the given element comparer.
+ *
+ * @param table
+ * the hash table to add from
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
+ this(table.size() * 2, comparer);
+ for (int i = table.elementData.length; --i >= 0;) {
+ HashMapEntry entry = table.elementData[i];
+ while (entry != null) {
+ put(entry.key, entry.value);
+ entry = entry.next;
+ }
+ }
+ }
+
+ private void computeMaxSize() {
+ threshold = (int) (elementData.length * loadFactor);
+ }
+
+ /**
+ * Answers if this Hashtable contains the specified object as a key of one
+ * of the key/value pairs.
+ *
+ * @param key
+ * the object to look for as a key in this Hashtable
+ * @return true if object is a key in this Hashtable, false otherwise
+ */
+ public boolean containsKey(Object key) {
+ return getEntry(key) != null;
+ }
+
+ /**
+ * Answers an Enumeration on the values of this Hashtable. The results of
+ * the Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the values of this Hashtable
+ */
+ public Enumeration elements() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(false);
+ }
+
+ /**
+ * Answers the value associated with the specified key in this Hashtable.
+ *
+ * @param key
+ * the key of the value returned
+ * @return the value associated with the specified key, null if the
+ * specified key does not exist
+ */
+ public Object get(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry.value;
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ private HashMapEntry getEntry(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry;
+ entry = entry.next;
+ }
+ return null;
+ }
+
+ /**
+ * Answers the hash code for the given key.
+ */
+ private int hashCode(Object key) {
+ if (comparer == null) {
+ return key.hashCode();
+ }
+ return comparer.hashCode(key);
+ }
+
+ /**
+ * Compares two keys for equality.
+ */
+ private boolean keyEquals(Object a, Object b) {
+ if (comparer == null) {
+ return a.equals(b);
+ }
+ return comparer.equals(a, b);
+ }
+
+ /**
+ * Answers an Enumeration on the keys of this Hashtable. The results of the
+ * Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the keys of this Hashtable
+ */
+ public Enumeration keys() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(true);
+ }
+
+ /**
+ * Associate the specified value with the specified key in this Hashtable.
+ * If the key already exists, the old value is replaced. The key and value
+ * cannot be null.
+ *
+ * @param key
+ * the key to add
+ * @param value
+ * the value to add
+ * @return the old value associated with the specified key, null if the key
+ * did not exist
+ */
+ public Object put(Object key, Object value) {
+ if (key != null && value != null) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key))
+ entry = entry.next;
+ if (entry == null) {
+ if (++elementCount > threshold) {
+ rehash();
+ index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ }
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ entry = new HashMapEntry(key, value);
+ entry.next = elementData[index];
+ elementData[index] = entry;
+ return null;
+ }
+ Object result = entry.value;
+ entry.key = key; // important to avoid hanging onto keys that are
+ // equal but "old" -- see bug 30607
+ entry.value = value;
+ return result;
+ }
+ throw new NullPointerException();
+ }
+
+ /**
+ * Increases the capacity of this Hashtable. This method is sent when the
+ * size of this Hashtable exceeds the load factor.
+ */
+ private void rehash() {
+ int length = elementData.length << 1;
+ if (length == 0)
+ length = 1;
+ firstSlot = length;
+ lastSlot = -1;
+ HashMapEntry[] newData = new HashMapEntry[length];
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ HashMapEntry next = entry.next;
+ entry.next = newData[index];
+ newData[index] = entry;
+ entry = next;
+ }
+ }
+ elementData = newData;
+ computeMaxSize();
+ }
+
+ /**
+ * Remove the key/value pair with the specified key from this Hashtable.
+ *
+ * @param key
+ * the key to remove
+ * @return the value associated with the specified key, null if the
+ * specified key did not exist
+ */
+ public Object remove(Object key) {
+ HashMapEntry last = null;
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key)) {
+ last = entry;
+ entry = entry.next;
+ }
+ if (entry != null) {
+ if (last == null)
+ elementData[index] = entry.next;
+ else
+ last.next = entry.next;
+ elementCount--;
+ return entry.value;
+ }
+ return null;
+ }
+
+ /**
+ * Answers the number of key/value pairs in this Hashtable.
+ *
+ * @return the number of key/value pairs in this Hashtable
+ */
+ public int size() {
+ return elementCount;
+ }
+
+ /**
+ * Answers the string representation of this Hashtable.
+ *
+ * @return the string representation of this Hashtable
+ */
+ @Override
public String toString() {
- if (size() == 0)
- return "{}"; //$NON-NLS-1$
-
- StringBuffer buffer = new StringBuffer();
- buffer.append('{');
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- buffer.append(entry.key);
- buffer.append('=');
- buffer.append(entry.value);
- buffer.append(", "); //$NON-NLS-1$
- entry = entry.next;
- }
- }
- // Remove the last ", "
- if (elementCount > 0)
- buffer.setLength(buffer.length() - 2);
- buffer.append('}');
- return buffer.toString();
- }
+ if (size() == 0)
+ return "{}"; //$NON-NLS-1$
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append('{');
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ buffer.append(entry.key);
+ buffer.append('=');
+ buffer.append(entry.value);
+ buffer.append(", "); //$NON-NLS-1$
+ entry = entry.next;
+ }
+ }
+ // Remove the last ", "
+ if (elementCount > 0)
+ buffer.setLength(buffer.length() - 2);
+ buffer.append('}');
+ return buffer.toString();
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java
index b97ec2778..9ccd4d405 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.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,13 +21,12 @@ import org.eclipse.ui.IWorkbenchActionConstants;
/**
* Adds view menus to switch between flat and hierarchical layout.
- *
- *
*/
public class LayoutActionGroup extends MultiActionGroup {
LayoutActionGroup(ScriptExplorerPart packageExplorer) {
- super(createActions(packageExplorer), getSelectedState(packageExplorer));
+ super(createActions(packageExplorer),
+ getSelectedState(packageExplorer));
}
@Override
@@ -49,27 +48,27 @@ public class LayoutActionGroup extends MultiActionGroup {
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
viewMenu.add(marker);
viewMenu.appendToGroup(layoutGroupName, layoutSubMenu);
- viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS
- + "-end"));//$NON-NLS-1$
+ viewMenu.add(
+ new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));//$NON-NLS-1$
addActions(layoutSubMenu);
}
static int getSelectedState(ScriptExplorerPart packageExplorer) {
- if (packageExplorer.isFlatLayout())
+ if (packageExplorer.isFlatLayout()) {
return 0;
- else
- return 1;
+ }
+ return 1;
}
static IAction[] createActions(ScriptExplorerPart packageExplorer) {
IAction flatLayoutAction = new LayoutAction(packageExplorer, true);
- flatLayoutAction
- .setText(ScriptMessages.LayoutActionGroup_flatLayoutAction_label);
+ flatLayoutAction.setText(
+ ScriptMessages.LayoutActionGroup_flatLayoutAction_label);
DLTKPluginImages.setLocalImageDescriptors(flatLayoutAction,
"flatLayout.png"); //$NON-NLS-1$
IAction hierarchicalLayout = new LayoutAction(packageExplorer, false);
- hierarchicalLayout
- .setText(ScriptMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
+ hierarchicalLayout.setText(
+ ScriptMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
DLTKPluginImages.setLocalImageDescriptors(hierarchicalLayout,
"hierarchicalLayout.png"); //$NON-NLS-1$
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 b16f6367c..212378db6 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
@@ -1095,9 +1095,8 @@ public class ScriptExplorerPart extends ViewPart implements ISetSelectionTarget,
je2 = DLTKCore.create(r);
if (je2 != null && je2.exists()) {
return je2;
- } else {
- return r;
}
+ return r;
}
}
return original;
@@ -1190,9 +1189,8 @@ public class ScriptExplorerPart extends ViewPart implements ISetSelectionTarget,
private int getLayoutAsInt() {
if (fIsCurrentLayoutFlat) {
return ScriptExplorerPart.FLAT_LAYOUT;
- } else {
- return ScriptExplorerPart.HIERARCHICAL_LAYOUT;
}
+ return ScriptExplorerPart.HIERARCHICAL_LAYOUT;
}
private void restoreFilterAndSorter() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java
index 58a96a086..005db32ae 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.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
@@ -211,11 +211,9 @@ public class SelectionTransferDropAdapter extends DLTKViewerDropAdapter
ScriptMessages.SelectionTransferDropAdapter_error_title,
ScriptMessages.SelectionTransferDropAdapter_error_message);
} catch (InvocationTargetException e) {
- ExceptionHandler
- .handle(
- e,
- RefactoringMessages.OpenRefactoringWizardAction_refactoring,
- RefactoringMessages.OpenRefactoringWizardAction_exception);
+ ExceptionHandler.handle(e,
+ RefactoringMessages.OpenRefactoringWizardAction_refactoring,
+ RefactoringMessages.OpenRefactoringWizardAction_exception);
} catch (InterruptedException e) {
// ok
}
@@ -239,9 +237,9 @@ public class SelectionTransferDropAdapter extends DLTKViewerDropAdapter
private int handleValidateMove(Object target) throws ModelException {
if (fMoveProcessor == null) {
- IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(ReorgUtils
- .getResources(fElements), ReorgUtils
- .getModelElements(fElements));
+ IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(
+ ReorgUtils.getResources(fElements),
+ ReorgUtils.getModelElements(fElements));
if (policy.canEnable())
fMoveProcessor = new ScriptMoveProcessor(policy);
}
@@ -298,10 +296,11 @@ public class SelectionTransferDropAdapter extends DLTKViewerDropAdapter
if (fCopyProcessor == null) {
final ICopyPolicy policy = ReorgPolicyFactory.createCopyPolicy(
- ReorgUtils.getResources(fElements), ReorgUtils
- .getModelElements(fElements));
- fCopyProcessor = policy.canEnable() ? new ScriptCopyProcessor(
- policy) : null;
+ ReorgUtils.getResources(fElements),
+ ReorgUtils.getModelElements(fElements));
+ fCopyProcessor = policy.canEnable()
+ ? new ScriptCopyProcessor(policy)
+ : null;
}
if (!canCopyElements())
@@ -357,15 +356,11 @@ public class SelectionTransferDropAdapter extends DLTKViewerDropAdapter
return getViewer().getControl().getShell();
}
- /**
- * {@inheritDoc}
- */
@Override
protected int getCurrentLocation() {
if (getFeedbackEnabled()) {
return super.getCurrentLocation();
- } else {
- return LOCATION_ON;
}
+ return LOCATION_ON;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java
index bd483a348..db42d555f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.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
@@ -127,46 +127,42 @@ public class WorkingSetDropAdapter extends DLTKViewerDropAdapter
return DND.DROP_MOVE;
}
return DND.DROP_NONE;
- } else {
- if (isOthersWorkingSet(fWorkingSet) && operation == DND.DROP_COPY)
- return DND.DROP_NONE;
+ }
+ if (isOthersWorkingSet(fWorkingSet) && operation == DND.DROP_COPY)
+ return DND.DROP_NONE;
- List realScriptElements = new ArrayList();
- List realResource = new ArrayList();
- ReorgUtils.splitIntoModelElementsAndResources(fElementsToAdds,
- realScriptElements, realResource);
- if (fElementsToAdds.length != realScriptElements.size()
- + realResource.size())
+ List realScriptElements = new ArrayList();
+ List realResource = new ArrayList();
+ ReorgUtils.splitIntoModelElementsAndResources(fElementsToAdds,
+ realScriptElements, realResource);
+ if (fElementsToAdds.length != realScriptElements.size()
+ + realResource.size())
+ return DND.DROP_NONE;
+ for (Iterator iter = realScriptElements.iterator(); iter.hasNext();) {
+ IModelElement element = (IModelElement) iter.next();
+ if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
return DND.DROP_NONE;
- for (Iterator iter = realScriptElements.iterator(); iter
- .hasNext();) {
- IModelElement element = (IModelElement) iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements,
- element))
- return DND.DROP_NONE;
- }
- for (Iterator iter = realResource.iterator(); iter.hasNext();) {
- IResource element = (IResource) iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements,
- element))
- return DND.DROP_NONE;
- }
- if (!(fSelection instanceof ITreeSelection)) {
+ }
+ for (Iterator iter = realResource.iterator(); iter.hasNext();) {
+ IResource element = (IResource) iter.next();
+ if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
+ return DND.DROP_NONE;
+ }
+ if (!(fSelection instanceof ITreeSelection)) {
+ return DND.DROP_COPY;
+ }
+ ITreeSelection treeSelection = (ITreeSelection) fSelection;
+ TreePath[] paths = treeSelection.getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (path.getSegmentCount() != 2)
return DND.DROP_COPY;
- }
- ITreeSelection treeSelection = (ITreeSelection) fSelection;
- TreePath[] paths = treeSelection.getPaths();
- for (int i = 0; i < paths.length; i++) {
- TreePath path = paths[i];
- if (path.getSegmentCount() != 2)
- return DND.DROP_COPY;
- if (!(path.getSegment(0) instanceof IWorkingSet))
- return DND.DROP_COPY;
- if (paths.length == 1) {
- IWorkingSet ws = (IWorkingSet) path.getSegment(0);
- if (WorkingSetIDs.OTHERS.equals(ws.getId()))
- return DND.DROP_MOVE;
- }
+ if (!(path.getSegment(0) instanceof IWorkingSet))
+ return DND.DROP_COPY;
+ if (paths.length == 1) {
+ IWorkingSet ws = (IWorkingSet) path.getSegment(0);
+ if (WorkingSetIDs.OTHERS.equals(ws.getId()))
+ return DND.DROP_MOVE;
}
}
if (operation == DND.DROP_DEFAULT)
@@ -302,9 +298,6 @@ public class WorkingSetDropAdapter extends DLTKViewerDropAdapter
fLocation = location;
}
- /**
- * {@inheritDoc}
- */
@Override
protected int getCurrentLocation() {
if (fLocation == -1)
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java
index c850153fe..df4811cd1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.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
@@ -91,8 +91,8 @@ public class DLTKSearchEditorOpener {
private ReusedEditorWatcher fReusedEditorWatcher;
- public IEditorPart openElement(Object element) throws PartInitException,
- ModelException {
+ public IEditorPart openElement(Object element)
+ throws PartInitException, ModelException {
IWorkbenchPage wbPage = DLTKUIPlugin.getActivePage();
final IEditorPart editor;
if (NewSearchUI.reuseEditor())
@@ -104,8 +104,8 @@ public class DLTKSearchEditorOpener {
return editor;
}
- public IEditorPart openMatch(Match match) throws PartInitException,
- ModelException {
+ public IEditorPart openMatch(Match match)
+ throws PartInitException, ModelException {
Object element = getElementToOpen(match);
return openElement(element);
}
@@ -131,7 +131,8 @@ public class DLTKSearchEditorOpener {
} else if (module instanceof SourceModule) {
String editorID = getEditorID(module);
IFile file = getFile(element);
- return showInEditor(wbPage, new FileEditorInput(file), editorID);
+ return showInEditor(wbPage, new FileEditorInput(file),
+ editorID);
}
}
@@ -159,12 +160,12 @@ public class DLTKSearchEditorOpener {
private String getEditorID(IFile file) throws PartInitException {
IEditorDescriptor desc = null;
- if (desc == null)
+ if (desc == null) {
return DLTKUIPlugin.getDefault().getWorkbench().getEditorRegistry()
.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)
.getId();
- else
- return desc.getId();
+ }
+ return desc.getId();
}
private String getEditorID(IModelElement module) throws PartInitException {
@@ -182,9 +183,8 @@ public class DLTKSearchEditorOpener {
return DLTKUIPlugin.getDefault().getWorkbench().getEditorRegistry()
.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)
.getId();
- } else {
- return desc.getId();
}
+ return desc.getId();
}
private boolean isPinned(IEditorPart editor) {
@@ -238,8 +238,8 @@ public class DLTKSearchEditorOpener {
else
setReusedEditor(null);
} catch (PartInitException ex) {
- MessageDialog.openError(DLTKUIPlugin
- .getActiveWorkbenchShell(),
+ MessageDialog.openError(
+ DLTKUIPlugin.getActiveWorkbenchShell(),
SearchMessages.Search_Error_openEditor_title,
SearchMessages.Search_Error_openEditor_message);
return null;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java
index 735cdafa8..3c375e5e3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.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
@@ -41,10 +41,9 @@ import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.Match;
-
public class DLTKSearchQuery implements ISearchQuery {
- private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.dltk.ui/perf/search/participants"; //$NON-NLS-1$
+ private static final String PERF_SEARCH_PARTICIPANT = "org.eclipse.dltk.ui/perf/search/participants"; //$NON-NLS-1$
private ISearchResult fResult;
private final QuerySpecification fPatternData;
@@ -53,7 +52,7 @@ public class DLTKSearchQuery implements ISearchQuery {
if (data == null) {
throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
}
- fPatternData= data;
+ fPatternData = data;
}
private static class SearchRequestor implements ISearchRequestor {
@@ -62,108 +61,150 @@ public class DLTKSearchQuery implements ISearchQuery {
@Override
public void reportMatch(Match match) {
- IMatchPresentation participant= fParticipant.getUIParticipant();
- if (participant == null || match.getElement() instanceof IModelElement || match.getElement() instanceof IResource) {
+ IMatchPresentation participant = fParticipant.getUIParticipant();
+ if (participant == null
+ || match.getElement() instanceof IModelElement
+ || match.getElement() instanceof IResource) {
fSearchResult.addMatch(match);
} else {
fSearchResult.addMatch(match, participant);
}
}
- protected SearchRequestor(IQueryParticipant participant, DLTKSearchResult result) {
+ protected SearchRequestor(IQueryParticipant participant,
+ DLTKSearchResult result) {
super();
- fParticipant= participant;
- fSearchResult= result;
+ fParticipant = participant;
+ fSearchResult = result;
}
}
@Override
public IStatus run(IProgressMonitor monitor) {
- final DLTKSearchResult textResult= (DLTKSearchResult) getSearchResult();
+ final DLTKSearchResult textResult = (DLTKSearchResult) getSearchResult();
textResult.removeAll();
// Don't need to pass in working copies in 3.0 here
- SearchEngine engine= new SearchEngine();
+ SearchEngine engine = new SearchEngine();
try {
- int totalTicks= 1000;
- IProject[] projects= DLTKSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
+ int totalTicks = 1000;
+ IProject[] projects = DLTKSearchScopeFactory.getInstance()
+ .getProjects(fPatternData.getScope());
final SearchParticipantRecord[] participantDescriptors = SearchParticipantsExtensionPoint
- .getInstance().getSearchParticipants(this.fPatternData.getScope().getLanguageToolkit(), projects);
- final int[] ticks= new int[participantDescriptors.length];
- for (int i= 0; i < participantDescriptors.length; i++) {
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
+ .getInstance().getSearchParticipants(
+ this.fPatternData.getScope().getLanguageToolkit(),
+ projects);
+ final int[] ticks = new int[participantDescriptors.length];
+ for (int i = 0; i < participantDescriptors.length; i++) {
+ final int iPrime = i;
+ ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
- ticks[iPrime]= 0;
- String message= SearchMessages.DLTKSearchQuery_error_participant_estimate;
- DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, exception));
+ ticks[iPrime] = 0;
+ String message = SearchMessages.DLTKSearchQuery_error_participant_estimate;
+ DLTKUIPlugin.log(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), 0, message,
+ exception));
}
@Override
public void run() throws Exception {
- ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData);
+ ticks[iPrime] = participantDescriptors[iPrime]
+ .getParticipant().estimateTicks(fPatternData);
}
};
SafeRunner.run(runnable);
- totalTicks+= ticks[i];
+ totalTicks += ticks[i];
}
SearchPattern pattern;
String stringPattern;
- IDLTKLanguageToolkit toolkit = this.fPatternData.getScope().getLanguageToolkit();
+ IDLTKLanguageToolkit toolkit = this.fPatternData.getScope()
+ .getLanguageToolkit();
if (fPatternData instanceof ElementQuerySpecification) {
- IModelElement element= ((ElementQuerySpecification) fPatternData).getElement();
- stringPattern= ScriptElementLabels.getDefault().getElementLabel(element, ScriptElementLabels.ALL_DEFAULT);
+ IModelElement element = ((ElementQuerySpecification) fPatternData)
+ .getElement();
+ stringPattern = ScriptElementLabels.getDefault()
+ .getElementLabel(element,
+ ScriptElementLabels.ALL_DEFAULT);
if (!element.exists()) {
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, Messages.format(SearchMessages.DLTKSearchQuery_error_element_does_not_exist, stringPattern), null);
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(),
+ 0,
+ Messages.format(
+ SearchMessages.DLTKSearchQuery_error_element_does_not_exist,
+ stringPattern),
+ null);
}
- pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE, toolkit);
+ pattern = SearchPattern.createPattern(element,
+ fPatternData.getLimitTo(),
+ SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE, toolkit);
} else {
PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
- stringPattern= patternSpec.getPattern();
- int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
+ stringPattern = patternSpec.getPattern();
+ int matchMode = getMatchMode(stringPattern)
+ | SearchPattern.R_ERASURE_MATCH;
if (patternSpec.isCaseSensitive())
matchMode |= SearchPattern.R_CASE_SENSITIVE;
- pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode, toolkit);
+ pattern = SearchPattern.createPattern(patternSpec.getPattern(),
+ patternSpec.getSearchFor(), patternSpec.getLimitTo(),
+ matchMode, toolkit);
}
if (pattern == null) {
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, Messages.format(SearchMessages.DLTKSearchQuery_error_unsupported_pattern, stringPattern), null);
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
+ Messages.format(
+ SearchMessages.DLTKSearchQuery_error_unsupported_pattern,
+ stringPattern),
+ null);
}
- monitor.beginTask(Messages.format(SearchMessages.DLTKSearchQuery_task_label, stringPattern), totalTicks);
- IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
-
- boolean ignorePotentials= NewSearchUI.arePotentialMatchesIgnored();
- NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
-
-
- engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
- for (int i= 0; i < participantDescriptors.length; i++) {
- final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
- final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
-
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
+ monitor.beginTask(
+ Messages.format(SearchMessages.DLTKSearchQuery_task_label,
+ stringPattern),
+ totalTicks);
+ IProgressMonitor mainSearchPM = new SubProgressMonitor(monitor,
+ 1000);
+
+ boolean ignorePotentials = NewSearchUI.arePotentialMatchesIgnored();
+ NewSearchResultCollector collector = new NewSearchResultCollector(
+ textResult, ignorePotentials);
+
+ engine.search(pattern,
+ new SearchParticipant[] {
+ SearchEngine.getDefaultSearchParticipant() },
+ fPatternData.getScope(), collector, mainSearchPM);
+ for (int i = 0; i < participantDescriptors.length; i++) {
+ final ISearchRequestor requestor = new SearchRequestor(
+ participantDescriptors[i].getParticipant(), textResult);
+ final IProgressMonitor participantPM = new SubProgressMonitor(
+ monitor, ticks[i]);
+
+ final int iPrime = i;
+ ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
- participantDescriptors[iPrime].getDescriptor().disable();
- String message= SearchMessages.DLTKSearchQuery_error_participant_search;
- DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, exception));
+ participantDescriptors[iPrime].getDescriptor()
+ .disable();
+ String message = SearchMessages.DLTKSearchQuery_error_participant_search;
+ DLTKUIPlugin.log(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), 0, message,
+ exception));
}
@Override
public void run() throws Exception {
- final IQueryParticipant participant= participantDescriptors[iPrime].getParticipant();
+ final IQueryParticipant participant = participantDescriptors[iPrime]
+ .getParticipant();
- final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
+ final PerformanceStats stats = PerformanceStats
+ .getStats(PERF_SEARCH_PARTICIPANT, participant);
stats.startRun();
- participant.search(requestor, fPatternData, participantPM);
+ participant.search(requestor, fPatternData,
+ participantPM);
stats.endRun();
}
@@ -175,8 +216,11 @@ public class DLTKSearchQuery implements ISearchQuery {
} catch (CoreException e) {
return e.getStatus();
}
- String message= Messages.format(SearchMessages.DLTKSearchQuery_status_ok_message, String.valueOf(textResult.getMatchCount()));
- return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, message, null);
+ String message = Messages.format(
+ SearchMessages.DLTKSearchQuery_status_ok_message,
+ String.valueOf(textResult.getMatchCount()));
+ return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, message,
+ null);
}
private int getMatchMode(String pattern) {
@@ -195,58 +239,81 @@ public class DLTKSearchQuery implements ISearchQuery {
public String getResultLabel(int nMatches) {
if (nMatches == 1) {
- String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() };
+ Object[] args = { getSearchPatternDescription(),
+ fPatternData.getScopeDescription() };
switch (fPatternData.getLimitTo()) {
// case IDLTKSearchConstants.IMPLEMENTORS:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularImplementorsPostfix, args);
- case IDLTKSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularDeclarationsPostfix, args);
- case IDLTKSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularReferencesPostfix, args);
- case IDLTKSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix, args);
+ case IDLTKSearchConstants.DECLARATIONS:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularDeclarationsPostfix,
+ args);
+ case IDLTKSearchConstants.REFERENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularReferencesPostfix,
+ args);
+ case IDLTKSearchConstants.ALL_OCCURRENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix,
+ args);
// case IDLTKSearchConstants.READ_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularReadReferencesPostfix, args);
// case IDLTKSearchConstants.WRITE_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix, args);
+ default:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix,
+ args);
}
- } else {
- Object[] args= { getSearchPatternDescription(), Integer.valueOf(nMatches), fPatternData.getScopeDescription() };
- switch (fPatternData.getLimitTo()) {
+ }
+ Object[] args = { getSearchPatternDescription(),
+ Integer.valueOf(nMatches), fPatternData.getScopeDescription() };
+ switch (fPatternData.getLimitTo()) {
// case IDLTKSearchConstants.IMPLEMENTORS:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralImplementorsPostfix, args);
- case IDLTKSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralDeclarationsPostfix, args);
- case IDLTKSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralReferencesPostfix, args);
- case IDLTKSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix, args);
+ case IDLTKSearchConstants.DECLARATIONS:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralDeclarationsPostfix,
+ args);
+ case IDLTKSearchConstants.REFERENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralReferencesPostfix,
+ args);
+ case IDLTKSearchConstants.ALL_OCCURRENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix,
+ args);
// case IDLTKSearchConstants.READ_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralReadReferencesPostfix, args);
// case IDLTKSearchConstants.WRITE_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix, args);
- }
+ default:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix,
+ args);
}
}
private String getSearchPatternDescription() {
if (fPatternData instanceof ElementQuerySpecification) {
- IModelElement element= ((ElementQuerySpecification) fPatternData).getElement();
- return ScriptElementLabels.getDefault().getElementLabel(element, ScriptElementLabels.ALL_DEFAULT
- | ScriptElementLabels.ALL_FULLY_QUALIFIED | ScriptElementLabels.USE_RESOLVED);
+ IModelElement element = ((ElementQuerySpecification) fPatternData)
+ .getElement();
+ return ScriptElementLabels.getDefault().getElementLabel(element,
+ ScriptElementLabels.ALL_DEFAULT
+ | ScriptElementLabels.ALL_FULLY_QUALIFIED
+ | ScriptElementLabels.USE_RESOLVED);
}
return ((PatternQuerySpecification) fPatternData).getPattern();
}
ImageDescriptor getImageDescriptor() {
- if (/*fPatternData.getLimitTo() == IDLTKSearchConstants.IMPLEMENTORS ||*/ fPatternData.getLimitTo() == IDLTKSearchConstants.DECLARATIONS)
+ if (/*
+ * fPatternData.getLimitTo() == IDLTKSearchConstants.IMPLEMENTORS ||
+ */ fPatternData
+ .getLimitTo() == IDLTKSearchConstants.DECLARATIONS) {
return DLTKPluginImages.DESC_OBJS_SEARCH_DECL;
- else
- return DLTKPluginImages.DESC_OBJS_SEARCH_REF;
+ }
+ return DLTKPluginImages.DESC_OBJS_SEARCH_REF;
}
@Override
@@ -262,7 +329,7 @@ public class DLTKSearchQuery implements ISearchQuery {
@Override
public ISearchResult getSearchResult() {
if (fResult == null) {
- fResult= new DLTKSearchResult(this);
+ fResult = new DLTKSearchResult(this);
new SearchResultUpdater((DLTKSearchResult) fResult);
}
return fResult;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java
index 0a810a350..c345d86a6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.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
@@ -487,15 +487,12 @@ public class DLTKSearchResultPage extends AbstractTextSearchViewPage
&& input.getActiveMatchFilters().length > 0) {
if (isQueryRunning()) {
String message = SearchMessages.DLTKSearchResultPage_filtered_message;
- return Messages.format(message, new Object[] { label });
-
- } else {
- int filteredOut = input.getMatchCount()
- - getFilteredMatchCount();
- String message = SearchMessages.DLTKSearchResultPage_filteredWithCount_message;
- return Messages.format(message,
- new Object[] { label, String.valueOf(filteredOut) });
+ return Messages.format(message, label);
+
}
+ int filteredOut = input.getMatchCount() - getFilteredMatchCount();
+ String message = SearchMessages.DLTKSearchResultPage_filteredWithCount_message;
+ return Messages.format(message, label, String.valueOf(filteredOut));
}
return label;
}
@@ -506,9 +503,8 @@ public class DLTKSearchResultPage extends AbstractTextSearchViewPage
ITreeContentProvider tp = (ITreeContentProvider) viewer
.getContentProvider();
return getMatchCount(tp, getRootElements((TreeViewer) getViewer()));
- } else {
- return getMatchCount((TableViewer) viewer);
}
+ return getMatchCount((TableViewer) viewer);
}
private Object[] getRootElements(TreeViewer viewer) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java
index 62dd15fc3..0fcdc9cbb 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.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
@@ -169,13 +169,13 @@ public class DLTKSearchScopeFactory {
String label = includeInterp
? SearchMessages.EnclosingProjectsScope2
: SearchMessages.EnclosingProjectsScope2NoInterpreterEnvironment;
- scopeDescription = Messages.format(label,
- new String[] { projectNames[0], projectNames[1] });
+ scopeDescription = Messages.format(label, projectNames[0],
+ projectNames[1]);
} else {
String label = includeInterp ? SearchMessages.EnclosingProjectsScope
: SearchMessages.EnclosingProjectsScopeNoInterpreterEnvironment;
- scopeDescription = Messages.format(label,
- new String[] { projectNames[0], projectNames[1] });
+ scopeDescription = Messages.format(label, projectNames[0],
+ projectNames[1]);
}
return scopeDescription;
}
@@ -185,11 +185,10 @@ public class DLTKSearchScopeFactory {
if (includeInterp) {
return Messages.format(SearchMessages.ProjectScope,
project.getElementName());
- } else {
- return Messages.format(
- SearchMessages.ProjectScopeNoInterpreterEnvironment,
- project.getElementName());
}
+ return Messages.format(
+ SearchMessages.ProjectScopeNoInterpreterEnvironment,
+ project.getElementName());
}
public String getProjectScopeDescription(IEditorInput editorInput,
@@ -207,7 +206,7 @@ public class DLTKSearchScopeFactory {
public String getHierarchyScopeDescription(IType type) {
return Messages.format(SearchMessages.HierarchyScope,
- new String[] { type.getElementName() });
+ type.getElementName());
}
public String getSelectionScopeDescription(IModelElement[] modelElements,
@@ -225,14 +224,14 @@ public class DLTKSearchScopeFactory {
String label = includeInterp ? SearchMessages.DoubleSelectionScope
: SearchMessages.DoubleSelectionScopeNoInterpreterEnvironment;
scopeDescription = Messages.format(label,
- new String[] { modelElements[0].getElementName(),
- modelElements[1].getElementName() });
+ modelElements[0].getElementName(),
+ modelElements[1].getElementName());
} else {
String label = includeInterp ? SearchMessages.SelectionScope
: SearchMessages.SelectionScopeNoInterpreterEnvironment;
scopeDescription = Messages.format(label,
- new String[] { modelElements[0].getElementName(),
- modelElements[1].getElementName() });
+ modelElements[0].getElementName(),
+ modelElements[1].getElementName());
}
return scopeDescription;
}
@@ -251,13 +250,13 @@ public class DLTKSearchScopeFactory {
if (workingSets.length == 2) {
String label = includeInterp ? SearchMessages.DoubleWorkingSetScope
: SearchMessages.DoubleWorkingSetScopeNoInterpreterEnvironment;
- return Messages.format(label, new String[] {
- workingSets[0].getLabel(), workingSets[1].getLabel() });
+ return Messages.format(label, workingSets[0].getLabel(),
+ workingSets[1].getLabel());
}
String label = includeInterp ? SearchMessages.WorkingSetsScope
: SearchMessages.WorkingSetsScopeNoInterpreterEnvironment;
- return Messages.format(label, new String[] { workingSets[0].getLabel(),
- workingSets[1].getLabel() });
+ return Messages.format(label, workingSets[0].getLabel(),
+ workingSets[1].getLabel());
}
public IProject[] getProjects(IDLTKSearchScope scope) {
@@ -276,9 +275,8 @@ public class DLTKSearchScopeFactory {
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
return getModelElements(
((IStructuredSelection) selection).toArray());
- } else {
- return new IModelElement[0];
}
+ return new IModelElement[0];
}
private IModelElement[] getModelElements(Object[] elements) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java
index 64ecb1685..333bd0d7d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.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
@@ -40,8 +40,8 @@ public class LevelTreeContentProvider extends DLTKSearchContentProvider
private static final int MAX_LEVEL = SCRIPT_ELEMENT_TYPES.length - 1;
private int fCurrentLevel;
- static class FastModelElementProvider extends
- StandardModelElementContentProvider {
+ static class FastModelElementProvider
+ extends StandardModelElementContentProvider {
@Override
public Object getParent(Object element) {
Object parent = getExtendedParent(element);
@@ -65,7 +65,8 @@ public class LevelTreeContentProvider extends DLTKSearchContentProvider
IModelElement modelElement = (IModelElement) possibleParent;
for (int j = fCurrentLevel; j < MAX_LEVEL + 1; j++) {
for (int i = 0; i < SCRIPT_ELEMENT_TYPES[j].length; i++) {
- if (modelElement.getElementType() == SCRIPT_ELEMENT_TYPES[j][i]) {
+ if (modelElement
+ .getElementType() == SCRIPT_ELEMENT_TYPES[j][i]) {
return null;
}
}
@@ -183,9 +184,8 @@ public class LevelTreeContentProvider extends DLTKSearchContentProvider
Set siblings = (Set) fChildrenMap.get(parent);
if (siblings != null) {
return siblings.remove(element);
- } else {
- return false;
}
+ return false;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java
index b26a0924c..ebd72b55a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.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
@@ -142,28 +142,26 @@ public abstract class SearchLabelProvider extends AppearanceAwareLabelProvider {
return Messages.format(
SearchMessages.SearchLabelProvider_exact_noCount,
elementName);
- } else {
- int exactCount = matchCount - potentialCount;
+ }
+ int exactCount = matchCount - potentialCount;
- if (potentialCount > 0 && exactCount > 0) {
- String[] args = new String[] { elementName,
- String.valueOf(matchCount), String.valueOf(exactCount),
- String.valueOf(potentialCount) };
- return Messages.format(
- SearchMessages.SearchLabelProvider_exact_and_potential_plural,
- args);
- } else if (exactCount == 0) {
- String[] args = new String[] { elementName,
- String.valueOf(matchCount) };
- return Messages.format(
- SearchMessages.SearchLabelProvider_potential_plural,
- args);
- }
- String[] args = new String[] { elementName,
+ if (potentialCount > 0 && exactCount > 0) {
+ Object[] args = new String[] { elementName,
+ String.valueOf(matchCount), String.valueOf(exactCount),
+ String.valueOf(potentialCount) };
+ return Messages.format(
+ SearchMessages.SearchLabelProvider_exact_and_potential_plural,
+ args);
+ } else if (exactCount == 0) {
+ Object[] args = new String[] { elementName,
String.valueOf(matchCount) };
return Messages.format(
- SearchMessages.SearchLabelProvider_exact_plural, args);
+ SearchMessages.SearchLabelProvider_potential_plural, args);
}
+ Object[] args = new String[] { elementName,
+ String.valueOf(matchCount) };
+ return Messages.format(SearchMessages.SearchLabelProvider_exact_plural,
+ args);
}
protected boolean hasChildren(Object elem) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java
index e6045d628..1eefe8817 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.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
@@ -12,26 +12,25 @@ import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-
public abstract class TextSearchLabelProvider extends LabelProvider {
private AbstractTextSearchViewPage fPage;
private String fMatchCountFormat;
public TextSearchLabelProvider(AbstractTextSearchViewPage page) {
- fPage= page;
- fMatchCountFormat= SearchMessages.TextSearchLabelProvider_matchCountFormat;
+ fPage = page;
+ fMatchCountFormat = SearchMessages.TextSearchLabelProvider_matchCountFormat;
}
@Override
public final String getText(Object element) {
- int matchCount= fPage.getInput().getMatchCount(element);
- String text= doGetText(element);
- if (matchCount < 2)
+ int matchCount = fPage.getInput().getMatchCount(element);
+ String text = doGetText(element);
+ if (matchCount < 2) {
return text;
- else {
- return Messages.format(fMatchCountFormat, new Object[] { text, Integer.valueOf(matchCount) });
}
+ return Messages.format(fMatchCountFormat,
+ new Object[] { text, Integer.valueOf(matchCount) });
}
protected abstract String doGetText(Object element);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java
index be6b12898..036d28fef 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.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
@@ -14,22 +14,22 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-
/**
* An <code>IDocument</code> based implementation of
- * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that
- * the supplied document is not copied; if the document is modified during the
- * lifetime of a <code>DocumentCharacterIterator</code>, the methods
- * returning document content may not always return the same values. Also, if
- * accessing the document fails with a {@link BadLocationException}, any of
+ * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that the
+ * supplied document is not copied; if the document is modified during the
+ * lifetime of a <code>DocumentCharacterIterator</code>, the methods returning
+ * document content may not always return the same values. Also, if accessing
+ * the document fails with a {@link BadLocationException}, any of
* <code>CharacterIterator</code> methods as well as <code>charAt</code>may
* return {@link CharacterIterator#DONE}.
*
- *
+ *
*/
-public class DocumentCharacterIterator implements CharacterIterator, CharSequence {
+public class DocumentCharacterIterator
+ implements CharacterIterator, CharSequence {
- private int fIndex= -1;
+ private int fIndex = -1;
private final IDocument fDocument;
private final int fFirst;
private final int fLast;
@@ -42,7 +42,8 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
/**
* Creates an iterator for the entire document.
*
- * @param document the document backing this iterator
+ * @param document
+ * the document backing this iterator
*/
public DocumentCharacterIterator(IDocument document) {
this(document, 0);
@@ -51,11 +52,15 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
/**
* Creates an iterator, starting at offset <code>first</code>.
*
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param document
+ * the document backing this iterator
+ * @param first
+ * the first character to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public DocumentCharacterIterator(IDocument document, int first) throws IllegalArgumentException {
+ public DocumentCharacterIterator(IDocument document, int first)
+ throws IllegalArgumentException {
this(document, first, document.getLength());
}
@@ -63,22 +68,27 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
* Creates an iterator for the document contents from <code>first</code>
* (inclusive) to <code>last</code> (exclusive).
*
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @param last the last character index to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param document
+ * the document backing this iterator
+ * @param first
+ * the first character to consider
+ * @param last
+ * the last character index to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public DocumentCharacterIterator(IDocument document, int first, int last) throws IllegalArgumentException {
+ public DocumentCharacterIterator(IDocument document, int first, int last)
+ throws IllegalArgumentException {
if (document == null)
throw new NullPointerException();
if (first < 0 || first > last)
throw new IllegalArgumentException();
if (last > document.getLength())
throw new IllegalArgumentException();
- fDocument= document;
- fFirst= first;
- fLast= last;
- fIndex= first;
+ fDocument = document;
+ fFirst = first;
+ fLast = last;
+ fIndex = first;
invariant();
}
@@ -89,10 +99,10 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
@Override
public char last() {
- if (fFirst == fLast)
+ if (fFirst == fLast) {
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ }
+ return setIndex(getEndIndex() - 1);
}
@Override
@@ -115,15 +125,14 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
@@ -168,20 +177,21 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
* was thrown when accessing the backing document.
* </p>
*
- * @param index {@inheritDoc}
+ * @param index
+ * {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public char charAt(int index) {
- if (index >= 0 && index < length())
+ if (index >= 0 && index < length()) {
try {
return fDocument.getChar(getBeginIndex() + index);
} catch (BadLocationException e) {
// ignore and return DONE
return DONE;
}
- else
- throw new IndexOutOfBoundsException();
+ }
+ throw new IndexOutOfBoundsException();
}
@Override
@@ -192,19 +202,19 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
throw new IndexOutOfBoundsException();
if (end > length())
throw new IndexOutOfBoundsException();
- return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end);
+ return new DocumentCharacterIterator(fDocument, getBeginIndex() + start,
+ getBeginIndex() + end);
}
@Override
public String toString() {
if (fFirst == 0 && fLast == fDocument.getLength()) {
return fDocument.get();
- } else {
- try {
- return fDocument.get(fFirst, length());
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
+ }
+ try {
+ return fDocument.get(fFirst, length());
+ } catch (BadLocationException e) {
+ throw new IndexOutOfBoundsException();
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java
index b5566c17c..c2c5a4d0b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.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
@@ -14,7 +14,6 @@ import org.eclipse.core.runtime.Assert;
import com.ibm.icu.text.BreakIterator;
-
/**
* A script break iterator. It returns all breaks, including before and after
* whitespace, and it returns all camel case breaks.
@@ -22,7 +21,7 @@ import com.ibm.icu.text.BreakIterator;
* A line break may be any of "\n", "\r", "\r\n", "\n\r".
* </p>
*
- *
+ *
*/
public class ScriptBreakIterator extends BreakIterator {
@@ -39,10 +38,11 @@ public class ScriptBreakIterator extends BreakIterator {
/**
* Returns <code>true</code> if this run consumes <code>ch</code>,
- * <code>false</code> otherwise. If <code>true</code> is returned,
- * the length of the receiver is adjusted accordingly.
+ * <code>false</code> otherwise. If <code>true</code> is returned, the
+ * length of the receiver is adjusted accordingly.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return <code>true</code> if <code>ch</code> was consumed
*/
protected boolean consume(char ch) {
@@ -54,10 +54,11 @@ public class ScriptBreakIterator extends BreakIterator {
}
/**
- * Whether this run accepts that character; does not update state. Called
- * from the default implementation of <code>consume</code>.
+ * Whether this run accepts that character; does not update state.
+ * Called from the default implementation of <code>consume</code>.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return <code>true</code> if <code>ch</code> is accepted
*/
protected abstract boolean isValid(char ch);
@@ -66,7 +67,7 @@ public class ScriptBreakIterator extends BreakIterator {
* Resets this run to the initial state.
*/
protected void init() {
- length= 0;
+ length = 0;
}
}
@@ -80,13 +81,13 @@ public class ScriptBreakIterator extends BreakIterator {
static final class LineDelimiter extends Run {
/** State: INIT -> delimiter -> EXIT. */
private char fState;
- private static final char INIT= '\0';
- private static final char EXIT= '\1';
+ private static final char INIT = '\0';
+ private static final char EXIT = '\1';
@Override
protected void init() {
super.init();
- fState= INIT;
+ fState = INIT;
}
@Override
@@ -95,11 +96,11 @@ public class ScriptBreakIterator extends BreakIterator {
return false;
if (fState == INIT) {
- fState= ch;
+ fState = ch;
length++;
return true;
} else if (fState != ch) {
- fState= EXIT;
+ fState = EXIT;
length++;
return true;
} else {
@@ -122,60 +123,61 @@ public class ScriptBreakIterator extends BreakIterator {
static final class CamelCaseIdentifier extends Run {
/* states */
- private static final int S_INIT= 0;
- private static final int S_LOWER= 1;
- private static final int S_ONE_CAP= 2;
- private static final int S_ALL_CAPS= 3;
- private static final int S_EXIT= 4;
- private static final int S_EXIT_MINUS_ONE= 5;
+ private static final int S_INIT = 0;
+ private static final int S_LOWER = 1;
+ private static final int S_ONE_CAP = 2;
+ private static final int S_ALL_CAPS = 3;
+ private static final int S_EXIT = 4;
+ private static final int S_EXIT_MINUS_ONE = 5;
/* character types */
- private static final int K_INVALID= 0;
- private static final int K_LOWER= 1;
- private static final int K_UPPER= 2;
- private static final int K_OTHER= 3;
+ private static final int K_INVALID = 0;
+ private static final int K_LOWER = 1;
+ private static final int K_UPPER = 2;
+ private static final int K_OTHER = 3;
private int fState;
- private final static int[][] MATRIX= new int[][] {
- // K_INVALID, K_LOWER, K_UPPER, K_OTHER
- { S_EXIT, S_LOWER, S_ONE_CAP, S_LOWER }, // S_INIT
- { S_EXIT, S_LOWER, S_EXIT, S_LOWER }, // S_LOWER
- { S_EXIT, S_LOWER, S_ALL_CAPS, S_LOWER }, // S_ONE_CAP
- { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_LOWER }, // S_ALL_CAPS
+ private final static int[][] MATRIX = new int[][] {
+ // K_INVALID, K_LOWER, K_UPPER, K_OTHER
+ { S_EXIT, S_LOWER, S_ONE_CAP, S_LOWER }, // S_INIT
+ { S_EXIT, S_LOWER, S_EXIT, S_LOWER }, // S_LOWER
+ { S_EXIT, S_LOWER, S_ALL_CAPS, S_LOWER }, // S_ONE_CAP
+ { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_LOWER }, // S_ALL_CAPS
};
@Override
protected void init() {
super.init();
- fState= S_INIT;
+ fState = S_INIT;
}
@Override
protected boolean consume(char ch) {
- int kind= getKind(ch);
- fState= MATRIX[fState][kind];
+ int kind = getKind(ch);
+ fState = MATRIX[fState][kind];
switch (fState) {
- case S_LOWER:
- case S_ONE_CAP:
- case S_ALL_CAPS:
- length++;
- return true;
- case S_EXIT:
- return false;
- case S_EXIT_MINUS_ONE:
- length--;
- return false;
- default:
- Assert.isTrue(false);
- return false;
+ case S_LOWER:
+ case S_ONE_CAP:
+ case S_ALL_CAPS:
+ length++;
+ return true;
+ case S_EXIT:
+ return false;
+ case S_EXIT_MINUS_ONE:
+ length--;
+ return false;
+ default:
+ Assert.isTrue(false);
+ return false;
}
}
/**
* Determines the kind of a character.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
*/
private int getKind(char ch) {
if (Character.isUpperCase(ch))
@@ -197,14 +199,16 @@ public class ScriptBreakIterator extends BreakIterator {
@Override
protected boolean isValid(char ch) {
- return !Character.isWhitespace(ch) && !Character.isJavaIdentifierPart(ch);
+ return !Character.isWhitespace(ch)
+ && !Character.isJavaIdentifierPart(ch);
}
}
- private static final Run WHITESPACE= new Whitespace();
- private static final Run DELIMITER= new LineDelimiter();
- private static final Run CAMELCASE= new CamelCaseIdentifier(); // new Identifier();
- private static final Run OTHER= new Other();
+ private static final Run WHITESPACE = new Whitespace();
+ private static final Run DELIMITER = new LineDelimiter();
+ private static final Run CAMELCASE = new CamelCaseIdentifier(); // new
+ // Identifier();
+ private static final Run OTHER = new Other();
/** The platform break iterator (word instance) used as a base. */
protected final BreakIterator fIterator;
@@ -213,13 +217,12 @@ public class ScriptBreakIterator extends BreakIterator {
/** our current position for the stateful methods. */
private int fIndex;
-
/**
* Creates a new break iterator.
*/
public ScriptBreakIterator() {
- fIterator= BreakIterator.getWordInstance();
- fIndex= fIterator.current();
+ fIterator = BreakIterator.getWordInstance();
+ fIndex = fIterator.current();
}
@Override
@@ -229,7 +232,7 @@ public class ScriptBreakIterator extends BreakIterator {
@Override
public int first() {
- fIndex= fIterator.first();
+ fIndex = fIterator.first();
return fIndex;
}
@@ -239,7 +242,7 @@ public class ScriptBreakIterator extends BreakIterator {
if (offset == getText().getEndIndex())
return DONE;
- int next= fIterator.following(offset);
+ int next = fIterator.following(offset);
if (next == DONE)
return DONE;
@@ -247,25 +250,27 @@ public class ScriptBreakIterator extends BreakIterator {
// Math.min(offset + run.length, next) does not work
// since BreakIterator.getWordInstance considers _ as boundaries
// seems to work fine, however
- Run run= consumeRun(offset);
+ Run run = consumeRun(offset);
return offset + run.length;
}
/**
* Consumes a run of characters at the limits of which we introduce a break.
- * @param offset the offset to start at
+ *
+ * @param offset
+ * the offset to start at
* @return the run that was consumed
*/
private Run consumeRun(int offset) {
// assert offset < length
- char ch= fText.charAt(offset);
- int length= fText.length();
- Run run= getRun(ch);
+ char ch = fText.charAt(offset);
+ int length = fText.length();
+ Run run = getRun(ch);
while (run.consume(ch) && offset < length - 1) {
offset++;
- ch= fText.charAt(offset);
+ ch = fText.charAt(offset);
}
return run;
@@ -274,19 +279,20 @@ public class ScriptBreakIterator extends BreakIterator {
/**
* Returns a run based on a character.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return the correct character given <code>ch</code>
*/
private Run getRun(char ch) {
Run run;
if (WHITESPACE.isValid(ch))
- run= WHITESPACE;
+ run = WHITESPACE;
else if (DELIMITER.isValid(ch))
- run= DELIMITER;
+ run = DELIMITER;
else if (CAMELCASE.isValid(ch))
- run= CAMELCASE;
+ run = CAMELCASE;
else if (OTHER.isValid(ch))
- run= OTHER;
+ run = OTHER;
else {
Assert.isTrue(false);
return null;
@@ -303,21 +309,21 @@ public class ScriptBreakIterator extends BreakIterator {
@Override
public boolean isBoundary(int offset) {
- if (offset == getText().getBeginIndex())
- return true;
- else
- return following(offset - 1) == offset;
+ if (offset == getText().getBeginIndex()) {
+ return true;
+ }
+ return following(offset - 1) == offset;
}
@Override
public int last() {
- fIndex= fIterator.last();
+ fIndex = fIterator.last();
return fIndex;
}
@Override
public int next() {
- fIndex= following(fIndex);
+ fIndex = following(fIndex);
return fIndex;
}
@@ -334,15 +340,15 @@ public class ScriptBreakIterator extends BreakIterator {
if (isBoundary(offset - 1))
return offset - 1;
- int previous= offset - 1;
+ int previous = offset - 1;
do {
- previous= fIterator.preceding(previous);
+ previous = fIterator.preceding(previous);
} while (!isBoundary(previous));
- int last= DONE;
+ int last = DONE;
while (previous < offset) {
- last= previous;
- previous= following(previous);
+ last = previous;
+ previous = following(previous);
}
return last;
@@ -350,7 +356,7 @@ public class ScriptBreakIterator extends BreakIterator {
@Override
public int previous() {
- fIndex= preceding(fIndex);
+ fIndex = preceding(fIndex);
return fIndex;
}
@@ -361,10 +367,12 @@ public class ScriptBreakIterator extends BreakIterator {
/**
* Creates a break iterator given a char sequence.
- * @param newText the new text
+ *
+ * @param newText
+ * the new text
*/
public void setText(CharSequence newText) {
- fText= newText;
+ fText = newText;
fIterator.setText(new SequenceCharacterIterator(newText));
first();
}
@@ -372,11 +380,12 @@ public class ScriptBreakIterator extends BreakIterator {
@Override
public void setText(CharacterIterator newText) {
if (newText instanceof CharSequence) {
- fText= (CharSequence) newText;
+ fText = (CharSequence) newText;
fIterator.setText(newText);
first();
} else {
- throw new UnsupportedOperationException("CharacterIterator not supported"); //$NON-NLS-1$
+ throw new UnsupportedOperationException(
+ "CharacterIterator not supported"); //$NON-NLS-1$
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java
index 37431a08b..7cd70d748 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.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
@@ -24,30 +24,32 @@ import org.eclipse.ui.IEditorPart;
/**
* Provides a Script element to be displayed in by an information presenter.
*/
-public class ScriptElementProvider implements IInformationProvider, IInformationProviderExtension {
+public class ScriptElementProvider
+ implements IInformationProvider, IInformationProviderExtension {
private ScriptEditor fEditor;
private boolean fUseCodeResolve;
public ScriptElementProvider(IEditorPart editor) {
- fUseCodeResolve= false;
+ fUseCodeResolve = false;
if (editor instanceof ScriptEditor)
- fEditor= (ScriptEditor)editor;
+ fEditor = (ScriptEditor) editor;
}
public ScriptElementProvider(IEditorPart editor, boolean useCodeResolve) {
this(editor);
- fUseCodeResolve= useCodeResolve;
+ fUseCodeResolve = useCodeResolve;
}
@Override
public IRegion getSubject(ITextViewer textViewer, int offset) {
if (textViewer != null && fEditor != null) {
- IRegion region= ScriptWordFinder.findWord(textViewer.getDocument(), offset);
- if (region != null)
+ IRegion region = ScriptWordFinder.findWord(textViewer.getDocument(),
+ offset);
+ if (region != null) {
return region;
- else
- return new Region(offset, 0);
+ }
+ return new Region(offset, 0);
}
return null;
}
@@ -64,11 +66,13 @@ public class ScriptElementProvider implements IInformationProvider, IInformation
try {
if (fUseCodeResolve) {
- IStructuredSelection sel= SelectionConverter.getStructuredSelection(fEditor);
+ IStructuredSelection sel = SelectionConverter
+ .getStructuredSelection(fEditor);
if (!sel.isEmpty())
return sel.getFirstElement();
}
- IModelElement element= SelectionConverter.getElementAtOffset(fEditor);
+ IModelElement element = SelectionConverter
+ .getElementAtOffset(fEditor);
if (element != null)
return element;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java
index 8eafa7141..06aef86c9 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.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
@@ -15,12 +15,10 @@ import org.eclipse.core.runtime.Assert;
/**
* A <code>CharSequence</code> based implementation of
* <code>CharacterIterator</code>.
- *
- *
*/
public class SequenceCharacterIterator implements CharacterIterator {
- private int fIndex= -1;
+ private int fIndex = -1;
private final CharSequence fSequence;
private final int fFirst;
private final int fLast;
@@ -33,7 +31,8 @@ public class SequenceCharacterIterator implements CharacterIterator {
/**
* Creates an iterator for the entire sequence.
*
- * @param sequence the sequence backing this iterator
+ * @param sequence
+ * the sequence backing this iterator
*/
public SequenceCharacterIterator(CharSequence sequence) {
this(sequence, 0);
@@ -42,33 +41,42 @@ public class SequenceCharacterIterator implements CharacterIterator {
/**
* Creates an iterator.
*
- * @param sequence the sequence backing this iterator
- * @param first the first character to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param sequence
+ * the sequence backing this iterator
+ * @param first
+ * the first character to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public SequenceCharacterIterator(CharSequence sequence, int first) throws IllegalArgumentException {
+ public SequenceCharacterIterator(CharSequence sequence, int first)
+ throws IllegalArgumentException {
this(sequence, first, sequence.length());
}
/**
* Creates an iterator.
*
- * @param sequence the sequence backing this iterator
- * @param first the first character to consider
- * @param last the last character index to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param sequence
+ * the sequence backing this iterator
+ * @param first
+ * the first character to consider
+ * @param last
+ * the last character index to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public SequenceCharacterIterator(CharSequence sequence, int first, int last) throws IllegalArgumentException {
+ public SequenceCharacterIterator(CharSequence sequence, int first, int last)
+ throws IllegalArgumentException {
if (sequence == null)
throw new NullPointerException();
if (first < 0 || first > last)
throw new IllegalArgumentException();
if (last > sequence.length())
throw new IllegalArgumentException();
- fSequence= sequence;
- fFirst= first;
- fLast= last;
- fIndex= first;
+ fSequence = sequence;
+ fFirst = first;
+ fLast = last;
+ fIndex = first;
invariant();
}
@@ -79,18 +87,18 @@ public class SequenceCharacterIterator implements CharacterIterator {
@Override
public char last() {
- if (fFirst == fLast)
+ if (fFirst == fLast) {
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ }
+ return setIndex(getEndIndex() - 1);
}
@Override
public char current() {
- if (fIndex >= fFirst && fIndex < fLast)
+ if (fIndex >= fFirst && fIndex < fLast) {
return fSequence.charAt(fIndex);
- else
- return DONE;
+ }
+ return DONE;
}
@Override
@@ -102,15 +110,14 @@ public class SequenceCharacterIterator implements CharacterIterator {
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java
index c9c6627e4..a321fe471 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.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
@@ -14,13 +14,14 @@ import java.io.Reader;
import org.eclipse.dltk.corext.documentation.SingleCharReader;
/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
+ * Reads the text contents from a reader and computes for each character a
+ * potential substitution. The substitution may eat more characters than only
+ * the one passed into the computation routine.
*/
public abstract class SubstitutionTextReader extends SingleCharReader {
- protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final String LINE_DELIM = System
+ .getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private Reader fReader;
protected boolean fWasWhiteSpace;
@@ -29,26 +30,25 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
/**
* Tells whether white space characters are skipped.
*/
- private boolean fSkipWhiteSpace= true;
+ private boolean fSkipWhiteSpace = true;
private boolean fReadFromBuffer;
private StringBuffer fBuffer;
private int fIndex;
-
protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuffer();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
+ fReader = reader;
+ fBuffer = new StringBuffer();
+ fIndex = 0;
+ fReadFromBuffer = false;
+ fCharAfterWhiteSpace = -1;
+ fWasWhiteSpace = true;
}
/**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
+ * Implement to compute the substitution for the given character and if
+ * necessary subsequent characters. Use <code>nextChar</code> to read
+ * subsequent characters.
*/
protected abstract String computeSubstitution(int c) throws IOException;
@@ -63,32 +63,31 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
* Returns the next character.
*/
protected int nextChar() throws IOException {
- fReadFromBuffer= (fBuffer.length() > 0);
+ fReadFromBuffer = (fBuffer.length() > 0);
if (fReadFromBuffer) {
- char ch= fBuffer.charAt(fIndex++);
+ char ch = fBuffer.charAt(fIndex++);
if (fIndex >= fBuffer.length()) {
fBuffer.setLength(0);
- fIndex= 0;
+ fIndex = 0;
}
return ch;
- } else {
- int ch= fCharAfterWhiteSpace;
- if (ch == -1) {
- ch= fReader.read();
- }
- if (fSkipWhiteSpace && Character.isWhitespace((char)ch)) {
- do {
- ch= fReader.read();
- } while (Character.isWhitespace((char)ch));
- if (ch != -1) {
- fCharAfterWhiteSpace= ch;
- return ' ';
- }
- } else {
- fCharAfterWhiteSpace= -1;
+ }
+ int ch = fCharAfterWhiteSpace;
+ if (ch == -1) {
+ ch = fReader.read();
+ }
+ if (fSkipWhiteSpace && Character.isWhitespace((char) ch)) {
+ do {
+ ch = fReader.read();
+ } while (Character.isWhitespace((char) ch));
+ if (ch != -1) {
+ fCharAfterWhiteSpace = ch;
+ return ' ';
}
- return ch;
+ } else {
+ fCharAfterWhiteSpace = -1;
}
+ return ch;
}
@Override
@@ -96,22 +95,22 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
int c;
do {
- c= nextChar();
+ c = nextChar();
while (!fReadFromBuffer && c != -1) {
- String s= computeSubstitution(c);
+ String s = computeSubstitution(c);
if (s == null)
break;
if (s.length() > 0)
fBuffer.insert(0, s);
- c= nextChar();
+ c = nextChar();
}
} while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' '));
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
+ fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n');
return c;
}
- @Override
+ @Override
public boolean ready() throws IOException {
return fReader.ready();
}
@@ -124,14 +123,14 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
@Override
public void reset() throws IOException {
fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
+ fWasWhiteSpace = true;
+ fCharAfterWhiteSpace = -1;
fBuffer.setLength(0);
- fIndex= 0;
+ fIndex = 0;
}
protected final void setSkipWhitespace(boolean state) {
- fSkipWhiteSpace= state;
+ fSkipWhiteSpace = state;
}
protected final boolean isSkippingWhitespace() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java
index 8c5243392..8816192df 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.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
@@ -221,7 +221,7 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
* Creates a new PresenterControlCreator.
*
* @param site
- * the site or <code>null</code> if none
+ * the site or <code>null</code> if none
*/
public PresenterControlCreator(IWorkbenchSite site) {
}
@@ -292,9 +292,8 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
// TODO (alex) addLinkListener(iControl);
return iControl;
- } else {
- return new DefaultInformationControl(parent, true);
}
+ return new DefaultInformationControl(parent, true);
}
}
@@ -339,7 +338,8 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
/**
* @param informationPresenterControlCreator
- * control creator for enriched hover
+ * control creator for
+ * enriched hover
*/
public HoverControlCreator(
IInformationControlCreator informationPresenterControlCreator) {
@@ -348,10 +348,15 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
/**
* @param informationPresenterControlCreator
- * control creator for enriched hover
+ * control creator for
+ * enriched hover
* @param additionalInfoAffordance
- * <code>true</code> to use the additional info affordance,
- * <code>false</code> to use the hover affordance
+ * <code>true</code> to
+ * use the additional info
+ * affordance,
+ * <code>false</code> to
+ * use the hover
+ * affordance
*/
public HoverControlCreator(
IInformationControlCreator informationPresenterControlCreator,
@@ -382,10 +387,9 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
};
// TODO (alex) addLinkListener(iControl);
return iControl;
- } else {
- return new DefaultInformationControl(parent,
- tooltipAffordanceString);
}
+ return new DefaultInformationControl(parent,
+ tooltipAffordanceString);
}
/**
@@ -595,9 +599,8 @@ public class DocumentationHover extends AbstractScriptEditorTextHover
String label = ScriptElementLabels.getDefault()
.getElementLabel(member, flags);
return label;
- } else {
- return null;
}
+ return null;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java
index 943cec7c1..71ce8ecb3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.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
@@ -77,8 +77,8 @@ public class EditorTextHoverDescriptor {
* Computes the state mask for the given modifier string.
*
* @param modifiers
- * the string with the modifiers, separated by '+', '-', ';', ','
- * or '.'
+ * the string with the modifiers, separated by '+',
+ * '-', ';', ',' or '.'
* @return the state mask or -1 if the input is invalid
*/
public static int computeStateMask(String modifiers) {
@@ -154,10 +154,10 @@ public class EditorTextHoverDescriptor {
// Return simple class name
label = getHoverClassName();
int lastDot = label.lastIndexOf('.');
- if (lastDot >= 0 && lastDot < label.length() - 1)
+ if (lastDot >= 0 && lastDot < label.length() - 1) {
return label.substring(lastDot + 1);
- else
- return label;
+ }
+ return label;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java
index da8d0f12f..3bceceb37 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.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
@@ -186,10 +186,10 @@ public class ScriptExpandHover extends AnnotationExpandHover {
@Override
protected int getOrder(Annotation annotation) {
- if (isBreakpointAnnotation(annotation))
+ if (isBreakpointAnnotation(annotation)) {
return 1000;
- else
- return super.getOrder(annotation);
+ }
+ return super.getOrder(annotation);
}
private boolean isBreakpointAnnotation(Annotation a) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
index 729bf853b..a6db21a55 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 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
@@ -29,8 +29,8 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
-public class ScriptInformationProvider implements IInformationProvider,
- IInformationProviderExtension2 {
+public class ScriptInformationProvider
+ implements IInformationProvider, IInformationProviderExtension2 {
class EditorWatcher implements IPartListener {
@@ -137,12 +137,12 @@ public class ScriptInformationProvider implements IInformationProvider,
@Override
public IInformationControl doCreateInformationControl(
Shell parent) {
- if (BrowserInformationControl.isAvailable(parent))
+ if (BrowserInformationControl.isAvailable(parent)) {
return new BrowserInformationControl(parent,
JFaceResources.DIALOG_FONT, true);
- else
- return new DefaultInformationControl(parent,
- new HTMLTextPresenter(false));
+ }
+ return new DefaultInformationControl(parent,
+ new HTMLTextPresenter(false));
}
};
}
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 a1dc7495b..1b90c0cb6 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
@@ -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
@@ -203,10 +203,9 @@ public abstract class HierarchyInformationControl
if (filterOverrides) {
return fMethodOverrideTester
.findOverriddenMethodInType(typeToFindIn, filterMethod);
- } else {
- return fMethodOverrideTester
- .findOverridingMethodInType(typeToFindIn, filterMethod);
}
+ return fMethodOverrideTester.findOverridingMethodInType(typeToFindIn,
+ filterMethod);
}
@Override
@@ -356,11 +355,10 @@ public abstract class HierarchyInformationControl
return Messages.format(
TypeHierarchyMessages.HierarchyInformationControl_toggle_traditionalhierarchy_label,
keyName);
- } else {
- 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/typehierarchy/OpenTypeHierarchyUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java
index 2c5b885d6..0bba2212a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.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
@@ -28,25 +28,28 @@ public class OpenTypeHierarchyUtil {
private OpenTypeHierarchyUtil() {
}
- public static TypeHierarchyViewPart open(IModelElement element, IWorkbenchWindow window) {
- IModelElement[] candidates= getCandidates(element);
+ public static TypeHierarchyViewPart open(IModelElement element,
+ IWorkbenchWindow window) {
+ IModelElement[] candidates = getCandidates(element);
if (candidates != null) {
return open(candidates, window);
}
return null;
}
- public static TypeHierarchyViewPart open(IModelElement[] candidates, IWorkbenchWindow window) {
+ public static TypeHierarchyViewPart open(IModelElement[] candidates,
+ IWorkbenchWindow window) {
Assert.isNotNull(candidates);
Assert.isTrue(candidates.length != 0);
- IModelElement input= null;
+ IModelElement input = null;
if (candidates.length > 1) {
- String title= DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_title;
- String message= DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_message;
- input= OpenActionUtil.selectModelElement(candidates, window.getShell(), title, message);
+ String title = DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_title;
+ String message = DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_message;
+ input = OpenActionUtil.selectModelElement(candidates,
+ window.getShell(), title, message);
} else {
- input= candidates[0];
+ input = candidates[0];
}
if (input instanceof IMember
&& input.getElementType() != IModelElement.TYPE) {
@@ -61,7 +64,7 @@ public class OpenTypeHierarchyUtil {
// PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.OPEN_TYPE_HIERARCHY))) {
// return openInPerspective(window, input);
// } else {
- return openInViewPart(window, input);
+ return openInViewPart(window, input);
// }
// } catch (WorkbenchException e) {
@@ -76,19 +79,24 @@ public class OpenTypeHierarchyUtil {
// return null;
}
- private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IModelElement input) {
- IWorkbenchPage page= window.getActivePage();
+ private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window,
+ IModelElement input) {
+ IWorkbenchPage page = window.getActivePage();
try {
- TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
+ TypeHierarchyViewPart result = (TypeHierarchyViewPart) page
+ .findView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
if (result != null) {
- result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
+ result.clearNeededRefresh(); // avoid refresh of old hierarchy
+ // on 'becomes visible'
}
- result= (TypeHierarchyViewPart) page.showView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
+ result = (TypeHierarchyViewPart) page
+ .showView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
result.setInputElement(input);
return result;
} catch (CoreException e) {
ExceptionHandler.handle(e, window.getShell(),
- DLTKUIMessages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
+ DLTKUIMessages.OpenTypeHierarchyUtil_error_open_view,
+ e.getMessage());
}
return null;
}
@@ -101,20 +109,19 @@ public class OpenTypeHierarchyUtil {
return null;
}
try {
- IModelElement elem= (IModelElement) input;
+ IModelElement elem = (IModelElement) input;
switch (elem.getElementType()) {
- case IModelElement.METHOD:
- case IModelElement.FIELD:
- case IModelElement.TYPE:
- case IModelElement.SCRIPT_PROJECT:
- return new IModelElement[] { elem };
+ case IModelElement.METHOD:
+ case IModelElement.FIELD:
+ case IModelElement.TYPE:
+ case IModelElement.SCRIPT_PROJECT:
+ return new IModelElement[] { elem };
case IModelElement.LOCAL_VARIABLE: {
final IType type = AdaptUtils.getAdapter(elem, IType.class);
if (type != null) {
return new IModelElement[] { type };
- } else {
- return null;
}
+ return null;
}
// case IModelElement.PROJECT_FRAGMENT:
// if (((IProjectFragment)elem).containsJavaResources())
@@ -135,17 +142,18 @@ public class OpenTypeHierarchyUtil {
//
// case IModelElement.CLASS_FILE:
// return new IModelElement[] { ((IClassFile)input).getType() };
- case IModelElement.SOURCE_MODULE: {
- ISourceModule cu= (ISourceModule) elem.getAncestor(IModelElement.SOURCE_MODULE);
- if (cu != null) {
- IType[] types= cu.getTypes();
- if (types.length > 0) {
- return types;
- }
+ case IModelElement.SOURCE_MODULE: {
+ ISourceModule cu = (ISourceModule) elem
+ .getAncestor(IModelElement.SOURCE_MODULE);
+ if (cu != null) {
+ IType[] types = cu.getTypes();
+ if (types.length > 0) {
+ return types;
}
- break;
}
- default:
+ break;
+ }
+ default:
}
} catch (ModelException e) {
DLTKUIPlugin.log(e);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
index e59476381..5f966018a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.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
@@ -17,23 +17,25 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
/**
- * A viewer including the content provider for the subtype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
+ * A viewer including the content provider for the subtype hierarchy. Used by
+ * the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle on
+ * construction (shared type hierarchy)
*/
public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
- public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part, IPreferenceStore store) {
- super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part, store);
+ public SubTypeHierarchyViewer(Composite parent,
+ TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part,
+ IPreferenceStore store) {
+ super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle,
+ part, store);
}
@Override
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.SubTypeHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.SubTypeHierarchyViewer_title;
}
+ return TypeHierarchyMessages.SubTypeHierarchyViewer_title;
}
@Override
@@ -42,7 +44,7 @@ public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
refresh();
if (expand) {
- int expandLevel= 2;
+ int expandLevel = 2;
if (isMethodFiltering()) {
expandLevel++;
}
@@ -54,25 +56,24 @@ public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
/**
* Content provider for the subtype hierarchy
*/
- public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ public static class SubTypeHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
+ public SubTypeHierarchyContentProvider(
+ TypeHierarchyLifeCycle lifeCycle) {
super(lifeCycle);
}
@Override
protected final void getTypesInHierarchy(IType type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
- IType[] types= hierarchy.getSubtypes(type);
- /*if (isObject(type)) {
- for (int i= 0; i < types.length; i++) {
- IType curr= types[i];
- if (!isAnonymousFromInterface(curr)) {
- res.add(curr);
- }
- }
- } else */{
- for (int i= 0; i < types.length; i++) {
+ IType[] types = hierarchy.getSubtypes(type);
+ /*
+ * if (isObject(type)) { for (int i= 0; i < types.length; i++) {
+ * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) {
+ * res.add(curr); } } } else
+ */ {
+ for (int i = 0; i < types.length; i++) {
res.add(types[i]);
}
}
@@ -82,7 +83,7 @@ public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
@Override
protected IType[] getParentType(IType type) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
return hierarchy.getSuperclass(type);
// dont handle interfaces
@@ -90,8 +91,6 @@ public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
return null;
}
-}
-
-
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
index 1701e7e12..7c70ab0ef 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.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
@@ -17,23 +17,25 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
/**
- * A viewer including the content provider for the supertype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
+ * A viewer including the content provider for the supertype hierarchy. Used by
+ * the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle on
+ * construction (shared type hierarchy)
*/
public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
- public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part, IPreferenceStore store) {
- super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part, store);
+ public SuperTypeHierarchyViewer(Composite parent,
+ TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part,
+ IPreferenceStore store) {
+ super(parent, new SuperTypeHierarchyContentProvider(lifeCycle),
+ lifeCycle, part, store);
}
@Override
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.SuperTypeHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
}
+ return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
}
@Override
@@ -49,18 +51,20 @@ public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
/*
* Content provider for the supertype hierarchy
*/
- public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ public static class SuperTypeHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
+ public SuperTypeHierarchyContentProvider(
+ TypeHierarchyLifeCycle lifeCycle) {
super(lifeCycle);
}
@Override
protected final void getTypesInHierarchy(IType type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
- IType[] types= hierarchy.getSupertypes(type);
- if( types != null ) {
- for (int i= 0; i < types.length; i++) {
+ IType[] types = hierarchy.getSupertypes(type);
+ if (types != null) {
+ for (int i = 0; i < types.length; i++) {
res.add(types[i]);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
index 31647f8f3..39768689c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.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
@@ -36,9 +36,8 @@ public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.TraditionalHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.TraditionalHierarchyViewer_title;
}
+ return TypeHierarchyMessages.TraditionalHierarchyViewer_title;
}
@Override
@@ -60,8 +59,8 @@ public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
/**
* Content provider for the 'traditional' type hierarchy.
*/
- public static class TraditionalHierarchyContentProvider extends
- TypeHierarchyContentProvider {
+ public static class TraditionalHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
public TraditionalHierarchyContentProvider(
TypeHierarchyLifeCycle provider) {
@@ -74,9 +73,8 @@ public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
IType input = hierarchy.getType();
if (input != null) {
return getDepth(hierarchy, input) + 2;
- } else {
- return 5;
}
+ return 5;
}
return 2;
}
@@ -84,7 +82,7 @@ public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
private int getDepth(ITypeHierarchy hierarchy, IType input) {
int max = 0;
IType[] superType = hierarchy.getSuperclass(input);
- if( superType == null ) {
+ if (superType == null) {
return 0;
}
for (int q = 0; q < superType.length; ++q) {
@@ -127,10 +125,10 @@ public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
IType[] types = hierarchy.getSubtypes(type);
/*
* if (isObject(type)) { for (int i= 0; i < types.length; i++) {
- * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) { //
- * no anonymous classes on 'Object' -> will be children of
+ * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) {
+ * // no anonymous classes on 'Object' -> will be children of
* interface res.add(curr); } } } else
- */{
+ */ {
boolean isHierarchyOnType = (hierarchy.getType() != null);
boolean isClass = true;// !Flags.isInterface(hierarchy.getCachedFlags(type));
if (isClass || isHierarchyOnType) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
index fc6ee0fac..195b78242 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.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
@@ -124,9 +124,8 @@ public abstract class TypeHierarchyContentProvider
boolean filterOverrides) throws ModelException {
if (filterOverrides) {
return fMethodOverrideTester.isSubsignature(filterMethod, method);
- } else {
- return fMethodOverrideTester.isSubsignature(method, filterMethod);
}
+ return fMethodOverrideTester.isSubsignature(method, filterMethod);
}
/**
@@ -352,9 +351,8 @@ public abstract class TypeHierarchyContentProvider
if (isInScope(type)) {
if (fMemberFilter != null) {
return hasMemberFilterChildren(type) || hasTypeChildren(type);
- } else {
- return true;
}
+ return true;
}
return hasTypeChildren(type);
}
@@ -409,9 +407,8 @@ public abstract class TypeHierarchyContentProvider
final IType[] parents = getParentType((IType) member);
if (parents != null && parents.length == 1) {
return parents[0];
- } else {
- return null;
}
+ return null;
}
return member.getDeclaringType();
} else if (element instanceof CumulativeType.Part) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
index 413823013..3dae8688d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.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
@@ -125,37 +125,34 @@ public class TypeHierarchyLifeCycle
IType type = (IType) element;
if (fIsSuperTypesOnly) {
return type.newSupertypeHierarchy(pm);
- } else {
- return type.newTypeHierarchy(pm);
}
- } else {
- IRegion region = DLTKCore.newRegion();
- if (element.getElementType() == IModelElement.SCRIPT_PROJECT) {
- // for projects only add the contained source folders
- IProjectFragment[] roots = ((IScriptProject) element)
- .getProjectFragments();
- for (int i = 0; i < roots.length; i++) {
- if (!roots[i].isExternal()) {
- region.add(roots[i]);
- }
+ return type.newTypeHierarchy(pm);
+ }
+ IRegion region = DLTKCore.newRegion();
+ if (element.getElementType() == IModelElement.SCRIPT_PROJECT) {
+ // for projects only add the contained source folders
+ IProjectFragment[] roots = ((IScriptProject) element)
+ .getProjectFragments();
+ for (int i = 0; i < roots.length; i++) {
+ if (!roots[i].isExternal()) {
+ region.add(roots[i]);
}
- } else if (element
- .getElementType() == IModelElement.PROJECT_FRAGMENT) {
- IProjectFragment[] roots = element.getScriptProject()
- .getProjectFragments();
- String name = element.getElementName();
- for (int i = 0; i < roots.length; i++) {
- IScriptFolder pack = roots[i].getScriptFolder(name);
- if (pack.exists()) {
- region.add(pack);
- }
+ }
+ } else if (element.getElementType() == IModelElement.PROJECT_FRAGMENT) {
+ IProjectFragment[] roots = element.getScriptProject()
+ .getProjectFragments();
+ String name = element.getElementName();
+ for (int i = 0; i < roots.length; i++) {
+ IScriptFolder pack = roots[i].getScriptFolder(name);
+ if (pack.exists()) {
+ region.add(pack);
}
- } else {
- region.add(element);
}
- IScriptProject jproject = element.getScriptProject();
- return jproject.newTypeHierarchy(region, pm);
+ } else {
+ region.add(element);
}
+ IScriptProject jproject = element.getScriptProject();
+ return jproject.newTypeHierarchy(region, pm);
}
public synchronized void doHierarchyRefresh(IModelElement element,
@@ -197,13 +194,11 @@ public class TypeHierarchyLifeCycle
if (fHierarchyRefreshNeeded) {
return;
- } else {
- ArrayList<IType> changedTypes = new ArrayList<>();
- processDelta(event.getDelta(), changedTypes);
- if (changedTypes.size() > 0) {
- fireChange(
- changedTypes.toArray(new IType[changedTypes.size()]));
- }
+ }
+ ArrayList<IType> changedTypes = new ArrayList<>();
+ processDelta(event.getDelta(), changedTypes);
+ if (changedTypes.size() > 0) {
+ fireChange(changedTypes.toArray(new IType[changedTypes.size()]));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
index 2cdf2072a..d9914e39f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
@@ -1138,9 +1138,8 @@ public class TypeHierarchyViewPart extends ViewPart
private IType getSelectableType(IModelElement elem) {
if (elem.getElementType() != IModelElement.TYPE) {
return getCurrentViewer().getTreeRootType();
- } else {
- return (IType) elem;
}
+ return (IType) elem;
}
private void internalSelectType(IMember elem, boolean reveal) {
@@ -1317,7 +1316,7 @@ public class TypeHierarchyViewPart extends ViewPart
if (fInputElement != null) {
IWorkingSet workingSet = fWorkingSetActionGroup.getWorkingSet();
if (workingSet == null) {
- String[] args = new String[] { viewerTitle,
+ Object[] args = new String[] { viewerTitle,
ScriptElementLabels.getDefault().getElementLabel(
fInputElement,
ScriptElementLabels.ALL_DEFAULT) };
@@ -1328,7 +1327,7 @@ public class TypeHierarchyViewPart extends ViewPart
TypeHierarchyMessages.TypeHierarchyViewPart_tooltip,
args);
} else {
- String[] args = new String[] { viewerTitle,
+ Object[] args = new String[] { viewerTitle,
ScriptElementLabels.getDefault().getElementLabel(
fInputElement, ScriptElementLabels.ALL_DEFAULT),
workingSet.getLabel() };
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java
index 797b2170d..74161a779 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.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,9 +52,9 @@ public class CoreUtility {
* cursor will be activated during the duration of the load.
*
* @param element
- * the config element defining the extension
+ * the config element defining the extension
* @param classAttribute
- * the name of the attribute carrying the class
+ * the name of the attribute carrying the class
* @return the extension object
*/
public static Object createExtension(final IConfigurationElement element,
@@ -65,29 +65,27 @@ public class CoreUtility {
Bundle bundle = Platform.getBundle(pluginId);
if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
return element.createExecutableExtension(classAttribute);
- } else {
- final Object[] ret = new Object[1];
- final CoreException[] exc = new CoreException[1];
- BusyIndicator.showWhile(null, () -> {
- try {
- ret[0] = element
- .createExecutableExtension(classAttribute);
- } catch (CoreException e) {
- exc[0] = e;
- }
- });
- if (exc[0] != null)
- throw exc[0];
- else
- return ret[0];
}
+ final Object[] ret = new Object[1];
+ final CoreException[] exc = new CoreException[1];
+ BusyIndicator.showWhile(null, () -> {
+ try {
+ ret[0] = element.createExecutableExtension(classAttribute);
+ } catch (CoreException e) {
+ exc[0] = e;
+ }
+ });
+ if (exc[0] != null) {
+ throw exc[0];
+ }
+ return ret[0];
}
/**
* Set the autobuild to the value of the parameter and return the old one.
*
* @param state
- * the value to be set for autobuilding.
+ * the value to be set for autobuilding.
* @return the old value of the autobuild state
*/
public static boolean enableAutoBuild(boolean state) throws CoreException {
@@ -122,8 +120,8 @@ public class CoreUtility {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- Job[] buildJobs = Job.getJobManager().find(
- ResourcesPlugin.FAMILY_MANUAL_BUILD);
+ Job[] buildJobs = Job.getJobManager()
+ .find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
for (int i = 0; i < buildJobs.length; i++) {
Job curr = buildJobs[i];
if (curr != this && curr instanceof BuildJob) {
@@ -172,14 +170,14 @@ public class CoreUtility {
* Returns a build job
*
* @param project
- * The project to build or <code>null</code> to build the
- * workspace.
+ * The project to build or <code>null</code> to build the
+ * workspace.
*/
public static Job getBuildJob(final IProject project) {
Job buildJob = new BuildJob(DLTKUIMessages.CoreUtility_job_title,
project);
- buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory()
- .buildRule());
+ buildJob.setRule(
+ ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
buildJob.setUser(true);
return buildJob;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java
index c2f597348..076f7e18e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.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
@@ -47,10 +47,10 @@ public class MethodNameMatchLabelProvider extends LabelProvider {
}
private String getPackageName(String packName) {
- if (packName.length() == 0)
+ if (packName.length() == 0) {
return DLTKUIMessages.TypeInfoLabelProvider_default_package;
- else
- return packName;
+ }
+ return packName;
}
@Override
@@ -105,8 +105,8 @@ public class MethodNameMatchLabelProvider extends LabelProvider {
if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
MethodNameMatch methodRef = (MethodNameMatch) element;
- if (methodRef.getPackageName().equals(
- methodRef.getMethodContainerName()))
+ if (methodRef.getPackageName()
+ .equals(methodRef.getMethodContainerName()))
return PKG_ICON;
return METHOD_ICON;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
index 53be09b98..bb69a5093 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.util;
@@ -21,259 +20,293 @@ public class StringMatcher {
protected boolean fIgnoreCase;
protected boolean fHasLeadingStar;
protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
+ protected String fSegments[]; // the given pattern is split into * separated
+ // segments
/* boundary value beyond which we don't need to search in the text */
- protected int fBound= 0;
-
+ protected int fBound = 0;
+
+ protected static final char fSingleWildCard = '\u0000';
- protected static final char fSingleWildCard= '\u0000';
-
public static class Position {
- int start; //inclusive
- int end; //exclusive
+ int start; // inclusive
+ int end; // exclusive
+
public Position(int start, int end) {
- this.start= start;
- this.end= end;
+ this.start = start;
+ this.end = end;
}
+
public int getStart() {
return start;
}
+
public int getEnd() {
return end;
}
}
+
/**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern. The pattern may contain '*' for 0 and many characters and
- * '?' for exactly one character.
+ * StringMatcher constructor takes in a String object that is a simple
+ * pattern. The pattern may contain '*' for 0 and many characters and '?'
+ * for exactly one character.
*
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
+ * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
+ * means literal "*", etc.
*
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
+ * Escaping any other character (including the escape character itself),
+ * just results in that character in the pattern. e.g., "\a" means "a" and
+ * "\\" means "\"
*
- * If invoking the StringMatcher with string literals in script lang., don't forget
- * escape characters are represented by "\\".
+ * If invoking the StringMatcher with string literals in script lang., don't
+ * forget escape characters are represented by "\\".
*
- * @param pattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
+ * @param pattern
+ * the pattern to match text against
+ * @param ignoreCase
+ * if true, case is ignored
+ * @param ignoreWildCards
+ * if true, wild cards and their escape sequences
+ * are ignored (everything is taken literally).
*/
- public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+ public StringMatcher(String pattern, boolean ignoreCase,
+ boolean ignoreWildCards) {
if (pattern == null)
throw new IllegalArgumentException();
- fIgnoreCase= ignoreCase;
- fIgnoreWildCards= ignoreWildCards;
- fPattern= pattern;
- fLength= pattern.length();
-
+ fIgnoreCase = ignoreCase;
+ fIgnoreWildCards = ignoreWildCards;
+ fPattern = pattern;
+ fLength = pattern.length();
+
if (fIgnoreWildCards) {
parseNoWildCards();
} else {
parseWildCards();
}
}
+
/**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param text the String object to search in
- * @param start the starting index of the search range, inclusive
- * @param end the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
+ * Find the first occurrence of the pattern between
+ * <code>start</code)(inclusive)
+ * and <code>end</code>(exclusive).
+ *
+ * @param text
+ * the String object to search in
+ * @param start
+ * the starting index of the search range, inclusive
+ * @param end
+ * the ending index of the search range, exclusive
+ * @return an <code>StringMatcher.Position</code> object that keeps the
+ * starting (inclusive) and ending positions (exclusive) of the
+ * first occurrence of the pattern in the specified range of the
+ * text; return null if not found or subtext is empty (start==end).
+ * A pair of zeros is returned if pattern is empty string Note that
+ * for pattern like "*abc*" with leading and trailing stars,
+ * position of "abc" is returned. For a pattern like"*??*" in text
+ * "abcdf", (1,3) is returned
*/
public StringMatcher.Position find(String text, int start, int end) {
if (text == null)
throw new IllegalArgumentException();
-
- int tlen= text.length();
+
+ int tlen = text.length();
if (start < 0)
- start= 0;
+ start = 0;
if (end > tlen)
- end= tlen;
- if (end < 0 ||start >= end )
+ end = tlen;
+ if (end < 0 || start >= end)
return null;
if (fLength == 0)
return new Position(start, start);
if (fIgnoreWildCards) {
- int x= posIn(text, start, end);
+ int x = posIn(text, start, end);
if (x < 0)
return null;
- return new Position(x, x+fLength);
+ return new Position(x, x + fLength);
}
- int segCount= fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
-
- int curPos= start;
- int matchStart= -1;
+ int segCount = fSegments.length;
+ if (segCount == 0)// pattern contains only '*'(s)
+ return new Position(start, end);
+
+ int curPos = start;
+ int matchStart = -1;
int i;
- for (i= 0; i < segCount && curPos < end; ++i) {
- String current= fSegments[i];
- int nextMatch= regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0 )
+ for (i = 0; i < segCount && curPos < end; ++i) {
+ String current = fSegments[i];
+ int nextMatch = regExpPosIn(text, curPos, end, current);
+ if (nextMatch < 0)
return null;
- if(i == 0)
- matchStart= nextMatch;
- curPos= nextMatch + current.length();
+ if (i == 0)
+ matchStart = nextMatch;
+ curPos = nextMatch + current.length();
}
if (i < segCount)
return null;
return new Position(matchStart, curPos);
}
+
/**
- * match the given <code>text</code> with the pattern
+ * match the given <code>text</code> with the pattern
+ *
* @return true if matched eitherwise false
- * @param text a String object
+ * @param text
+ * a String object
*/
public boolean match(String text) {
return match(text, 0, text.length());
}
+
/**
- * Given the starting (inclusive) and the ending (exclusive) positions in the
- * <code>text</code>, determine if the given substring matches with aPattern
+ * Given the starting (inclusive) and the ending (exclusive) positions in
+ * the <code>text</code>, determine if the given substring matches with
+ * aPattern
+ *
* @return true if the specified portion of the text matches the pattern
- * @param text a String object that contains the substring to match
- * @param start marks the starting position (inclusive) of the substring
- * @param end marks the ending index (exclusive) of the substring
+ * @param text
+ * a String object that contains the substring to match
+ * @param start
+ * marks the starting position (inclusive) of the substring
+ * @param end
+ * marks the ending index (exclusive) of the substring
*/
public boolean match(String text, int start, int end) {
if (null == text)
throw new IllegalArgumentException();
-
+
if (start > end)
return false;
-
+
if (fIgnoreWildCards)
- return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s)
+ return (end - start == fLength) && fPattern
+ .regionMatches(fIgnoreCase, 0, text, start, fLength);
+ int segCount = fSegments.length;
+ if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern
+ // contains
+ // only
+ // '*'(s)
return true;
if (start == end)
return fLength == 0;
if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
+ return start == end;
+
+ int tlen = text.length();
if (start < 0)
- start= 0;
+ start = 0;
if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if ( bound < 0)
+ end = tlen;
+
+ int tCurPos = start;
+ int bound = end - fBound;
+ if (bound < 0)
return false;
- int i=0;
- String current= fSegments[i];
- int segLength= current.length();
+ int i = 0;
+ String current = fSegments[i];
+ int segLength = current.length();
/* process first segment */
- if (!fHasLeadingStar){
- if(!regExpRegionMatches(text, start, current, 0, segLength)) {
+ if (!fHasLeadingStar) {
+ if (!regExpRegionMatches(text, start, current, 0, segLength)) {
return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
}
+ ++i;
+ tCurPos = tCurPos + segLength;
}
- if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
+ if ((fSegments.length == 1) && (!fHasLeadingStar)
+ && (!fHasTrailingStar)) {
// only one segment to match, no wildcards specified
return tCurPos == end;
}
- /* process middle segments */
+ /* process middle segments */
while (i < segCount) {
- current= fSegments[i];
+ current = fSegments[i];
int currentMatch;
- int k= current.indexOf(fSingleWildCard);
+ int k = current.indexOf(fSingleWildCard);
if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
+ currentMatch = textPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current);
+ } else {
+ currentMatch = regExpPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
}
- tCurPos= currentMatch + current.length();
+ tCurPos = currentMatch + current.length();
i++;
}
/* process final segment */
if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
+ int clen = current.length();
return regExpRegionMatches(text, end - clen, current, 0, clen);
}
- return i == segCount ;
+ return i == segCount;
}
/**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
+ * This method parses the given pattern into segments seperated by wildcard
+ * '*' characters. Since wildcards are not being used in this case, the
+ * pattern consists of a single segment.
*/
private void parseNoWildCards() {
- fSegments= new String[1];
- fSegments[0]= fPattern;
- fBound= fLength;
+ fSegments = new String[1];
+ fSegments[0] = fPattern;
+ fBound = fLength;
}
+
/**
- * Parses the given pattern into segments seperated by wildcard '*' characters.
+ * Parses the given pattern into segments seperated by wildcard '*'
+ * characters.
*/
private void parseWildCards() {
- if(fPattern.startsWith("*"))//$NON-NLS-1$
- fHasLeadingStar= true;
- if(fPattern.endsWith("*")) {//$NON-NLS-1$
+ if (fPattern.startsWith("*"))//$NON-NLS-1$
+ fHasLeadingStar = true;
+ if (fPattern.endsWith("*")) {//$NON-NLS-1$
/* make sure it's not an escaped wildcard */
if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar= true;
+ fHasTrailingStar = true;
}
}
- Vector temp= new Vector();
+ Vector temp = new Vector();
- int pos= 0;
- StringBuffer buf= new StringBuffer();
+ int pos = 0;
+ StringBuffer buf = new StringBuffer();
while (pos < fLength) {
- char c= fPattern.charAt(pos++);
+ char c = fPattern.charAt(pos++);
switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
+ case '\\':
+ if (pos >= fLength) {
+ buf.append(c);
+ } else {
+ char next = fPattern.charAt(pos++);
+ /* if it's an escape sequence */
+ if (next == '*' || next == '?' || next == '\\') {
+ buf.append(next);
} else {
- char next= fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
+ /* not an escape sequence, just insert literally */
+ buf.append(c);
+ buf.append(next);
}
+ }
break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
+ case '*':
+ if (buf.length() > 0) {
+ /* new segment */
+ temp.addElement(buf.toString());
+ fBound += buf.length();
+ buf.setLength(0);
+ }
break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
+ case '?':
+ /*
+ * append special character representing single match wildcard
+ */
+ buf.append(fSingleWildCard);
break;
- default:
- buf.append(c);
+ default:
+ buf.append(c);
}
}
@@ -282,56 +315,68 @@ public class StringMatcher {
temp.addElement(buf.toString());
fBound += buf.length();
}
-
- fSegments= new String[temp.size()];
+
+ fSegments = new String[temp.size()];
temp.copyInto(fSegments);
}
- /**
- * @param text a string which contains no wildcard
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * a string which contains no wildcard
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- int max= end - fLength;
-
+ protected int posIn(String text, int start, int end) {// no wild card in
+ // pattern
+ int max = end - fLength;
+
if (!fIgnoreCase) {
- int i= text.indexOf(fPattern, start);
+ int i = text.indexOf(fPattern, start);
if (i == -1 || i > max)
return -1;
return i;
}
-
- for (int i= start; i <= max; ++i) {
+
+ for (int i = start; i <= max; ++i) {
if (text.regionMatches(true, i, fPattern, 0, fLength))
return i;
}
-
+
return -1;
}
- /**
- * @param text a simple regular expression that may only contain '?'(s)
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a simple regular expression that may contains '?'
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * a simple regular expression that may only contain '?'(s)
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a simple regular expression that may contains '?'
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
protected int regExpPosIn(String text, int start, int end, String p) {
- int plen= p.length();
-
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
+ int plen = p.length();
+
+ int max = end - plen;
+ for (int i = start; i <= max; ++i) {
if (regExpRegionMatches(text, i, p, 0, plen))
return i;
}
return -1;
}
-
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
+ protected boolean regExpRegionMatches(String text, int tStart, String p,
+ int pStart, int plen) {
while (plen-- > 0) {
- char tchar= text.charAt(tStart++);
- char pchar= p.charAt(pStart++);
+ char tchar = text.charAt(tStart++);
+ char pchar = p.charAt(pStart++);
/* process wild cards */
if (!fIgnoreWildCards) {
@@ -343,41 +388,50 @@ public class StringMatcher {
if (pchar == tchar)
continue;
if (fIgnoreCase) {
- if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar))
+ if (Character.toUpperCase(tchar) == Character
+ .toUpperCase(pchar))
continue;
- // comparing after converting to upper case doesn't handle all cases;
+ // comparing after converting to upper case doesn't handle all
+ // cases;
// also compare after converting to lower case
- if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar))
+ if (Character.toLowerCase(tchar) == Character
+ .toLowerCase(pchar))
continue;
}
return false;
}
return true;
}
- /**
- * @param text the string to match
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a string that has no wildcard
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * the string to match
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a string that has no wildcard
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen= p.length();
- int max= end - plen;
-
+ protected int textPosIn(String text, int start, int end, String p) {
+
+ int plen = p.length();
+ int max = end - plen;
+
if (!fIgnoreCase) {
- int i= text.indexOf(p, start);
+ int i = text.indexOf(p, start);
if (i == -1 || i > max)
return -1;
return i;
}
-
- for (int i= start; i <= max; ++i) {
+
+ for (int i = start; i <= max; ++i) {
if (text.regionMatches(true, i, p, 0, plen))
return i;
}
-
+
return -1;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java
index def1993a8..dbc0bca4e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.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,18 +23,21 @@ import org.eclipse.swt.graphics.Image;
*/
public class TypeNameMatchLabelProvider extends LabelProvider {
- public static final int SHOW_FULLYQUALIFIED= 0x01;
- public static final int SHOW_PACKAGE_POSTFIX= 0x02;
- public static final int SHOW_PACKAGE_ONLY= 0x04;
- public static final int SHOW_ROOT_POSTFIX= 0x08;
- public static final int SHOW_TYPE_ONLY= 0x10;
- public static final int SHOW_TYPE_CONTAINER_ONLY= 0x20;
- public static final int SHOW_POST_QUALIFIED= 0x40;
+ public static final int SHOW_FULLYQUALIFIED = 0x01;
+ public static final int SHOW_PACKAGE_POSTFIX = 0x02;
+ public static final int SHOW_PACKAGE_ONLY = 0x04;
+ public static final int SHOW_ROOT_POSTFIX = 0x08;
+ public static final int SHOW_TYPE_ONLY = 0x10;
+ public static final int SHOW_TYPE_CONTAINER_ONLY = 0x20;
+ public static final int SHOW_POST_QUALIFIED = 0x40;
- private static final Image CLASS_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_CLASS);
- private static final Image ANNOTATION_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_ANNOTATION);
+ private static final Image CLASS_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_CLASS);
+ private static final Image ANNOTATION_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_ANNOTATION);
// private static final Image INTERFACE_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_INTERFACE);
- private static final Image PKG_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_PACKAGE);
+ private static final Image PKG_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_PACKAGE);
private final int fFlags;
private final IDLTKUILanguageToolkit fToolkit;
@@ -43,12 +46,13 @@ public class TypeNameMatchLabelProvider extends LabelProvider {
* Creates the label provider with the specified parameters.
*
* @param flags
- * bitwise OR of the flags defined in this class
+ * bitwise OR of the flags defined in this class
* @param toolkit
- * language specific UI-toolkit to be used
+ * language specific UI-toolkit to be used
*/
- public TypeNameMatchLabelProvider(int flags, IDLTKUILanguageToolkit toolkit) {
- fFlags= flags;
+ public TypeNameMatchLabelProvider(int flags,
+ IDLTKUILanguageToolkit toolkit) {
+ fFlags = flags;
this.fToolkit = toolkit;
}
@@ -57,33 +61,33 @@ public class TypeNameMatchLabelProvider extends LabelProvider {
}
private String getPackageName(String packName) {
- if (packName.length() == 0)
+ if (packName.length() == 0) {
return DLTKUIMessages.TypeInfoLabelProvider_default_package;
- else
- return packName;
+ }
+ return packName;
}
@Override
public String getText(Object element) {
- if (! (element instanceof TypeNameMatch))
+ if (!(element instanceof TypeNameMatch))
return super.getText(element);
- TypeNameMatch typeRef= (TypeNameMatch) element;
- StringBuffer buf= new StringBuffer();
+ TypeNameMatch typeRef = (TypeNameMatch) element;
+ StringBuffer buf = new StringBuffer();
if (isSet(SHOW_TYPE_ONLY)) {
buf.append(typeRef.getSimpleTypeName());
} else if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
- String containerName= typeRef.getTypeContainerName();
+ String containerName = typeRef.getTypeContainerName();
buf.append(getPackageName(containerName));
} else if (isSet(SHOW_PACKAGE_ONLY)) {
- String packName= typeRef.getPackageName();
+ String packName = typeRef.getPackageName();
buf.append(getPackageName(packName));
} else {
if (isSet(SHOW_FULLYQUALIFIED)) {
buf.append(typeRef.getFullyQualifiedName());
} else if (isSet(SHOW_POST_QUALIFIED)) {
buf.append(typeRef.getSimpleTypeName());
- String containerName= typeRef.getTypeContainerName();
+ String containerName = typeRef.getTypeContainerName();
if (containerName != null && containerName.length() > 0) {
buf.append(ScriptElementLabels.CONCAT_STRING);
buf.append(containerName);
@@ -94,26 +98,27 @@ public class TypeNameMatchLabelProvider extends LabelProvider {
if (isSet(SHOW_PACKAGE_POSTFIX)) {
buf.append(ScriptElementLabels.CONCAT_STRING);
- String packName= typeRef.getPackageName();
+ String packName = typeRef.getPackageName();
buf.append(getPackageName(packName));
}
}
if (isSet(SHOW_ROOT_POSTFIX)) {
buf.append(ScriptElementLabels.CONCAT_STRING);
- IProjectFragment root= typeRef.getProjectFragment();
+ IProjectFragment root = typeRef.getProjectFragment();
ScriptElementLabels labels = this.fToolkit.getScriptElementLabels();
- labels.getProjectFragmentLabel(root, ScriptElementLabels.ROOT_QUALIFIED, buf);
+ labels.getProjectFragmentLabel(root,
+ ScriptElementLabels.ROOT_QUALIFIED, buf);
}
return buf.toString();
}
@Override
public Image getImage(Object element) {
- if (! (element instanceof TypeNameMatch))
+ if (!(element instanceof TypeNameMatch))
return super.getImage(element);
if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
- TypeNameMatch typeRef= (TypeNameMatch) element;
+ TypeNameMatch typeRef = (TypeNameMatch) element;
if (typeRef.getPackageName().equals(typeRef.getTypeContainerName()))
return PKG_ICON;
@@ -123,8 +128,8 @@ public class TypeNameMatchLabelProvider extends LabelProvider {
} else if (isSet(SHOW_PACKAGE_ONLY)) {
return PKG_ICON;
} else {
- int modifiers= ((TypeNameMatch)element).getModifiers();
- if ((modifiers & Modifiers.AccAnnotation ) != 0 ) {
+ int modifiers = ((TypeNameMatch) element).getModifiers();
+ if ((modifiers & Modifiers.AccAnnotation) != 0) {
return ANNOTATION_ICON;
}
// else if (Flags.isInterface(modifiers)) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java
index fe78340c5..380fad809 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.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
@@ -15,7 +15,8 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-public class AccessRulesLabelProvider extends LabelProvider implements ITableLabelProvider {
+public class AccessRulesLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
public AccessRulesLabelProvider() {
}
@@ -23,7 +24,7 @@ public class AccessRulesLabelProvider extends LabelProvider implements ITableLab
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof IAccessRule) {
- IAccessRule rule= (IAccessRule) element;
+ IAccessRule rule = (IAccessRule) element;
if (columnIndex == 0) {
return getResolutionImage(rule.getKind());
}
@@ -34,37 +35,38 @@ public class AccessRulesLabelProvider extends LabelProvider implements ITableLab
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof IAccessRule) {
- IAccessRule rule= (IAccessRule) element;
+ IAccessRule rule = (IAccessRule) element;
if (columnIndex == 0) {
return getResolutionLabel(rule.getKind());
- } else {
- return rule.getPattern().toString();
}
+ return rule.getPattern().toString();
}
return element.toString();
}
public static Image getResolutionImage(int kind) {
switch (kind) {
- case IAccessRule.K_ACCESSIBLE:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_NLS_TRANSLATE);
- case IAccessRule.K_DISCOURAGED:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_REFACTORING_WARNING);
- case IAccessRule.K_NON_ACCESSIBLE:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_REFACTORING_ERROR);
+ case IAccessRule.K_ACCESSIBLE:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_NLS_TRANSLATE);
+ case IAccessRule.K_DISCOURAGED:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_REFACTORING_WARNING);
+ case IAccessRule.K_NON_ACCESSIBLE:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_REFACTORING_ERROR);
}
return null;
}
-
public static String getResolutionLabel(int kind) {
switch (kind) {
- case IAccessRule.K_ACCESSIBLE:
- return NewWizardMessages.AccessRulesLabelProvider_kind_accessible;
- case IAccessRule.K_DISCOURAGED:
- return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged;
- case IAccessRule.K_NON_ACCESSIBLE:
- return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible;
+ case IAccessRule.K_ACCESSIBLE:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_accessible;
+ case IAccessRule.K_DISCOURAGED:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged;
+ case IAccessRule.K_NON_ACCESSIBLE:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible;
}
return ""; //$NON-NLS-1$
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java
index 6b079a3ed..69dae623a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.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
@@ -25,52 +25,60 @@ public class AddSourceFolderWizard extends BuildPathWizard {
private final boolean fCanCommitConflict;
private final IContainer fParent;
- public AddSourceFolderWizard(BPListElement[] existingEntries, BPListElement newEntry,
- boolean linkedMode, boolean canCommitConflict,
- boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns) {
- this(existingEntries, newEntry, linkedMode, canCommitConflict, allowConflict, allowRemoveProjectFolder, allowAddExclusionPatterns, newEntry.getScriptProject().getProject());
+ public AddSourceFolderWizard(BPListElement[] existingEntries,
+ BPListElement newEntry, boolean linkedMode,
+ boolean canCommitConflict, boolean allowConflict,
+ boolean allowRemoveProjectFolder,
+ boolean allowAddExclusionPatterns) {
+ this(existingEntries, newEntry, linkedMode, canCommitConflict,
+ allowConflict, allowRemoveProjectFolder,
+ allowAddExclusionPatterns,
+ newEntry.getScriptProject().getProject());
}
- public AddSourceFolderWizard(BPListElement[] existingEntries, BPListElement newEntry,
- boolean linkedMode, boolean canCommitConflict,
- boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns, IContainer parent) {
- super(existingEntries, newEntry, getTitel(newEntry, linkedMode), DLTKPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
- fLinkedMode= linkedMode;
- fCanCommitConflict= canCommitConflict;
- fAllowConflict= allowConflict;
- fAllowRemoveProjectFolder= allowRemoveProjectFolder;
- fAllowAddExclusionPatterns= allowAddExclusionPatterns;
- fParent= parent;
+ public AddSourceFolderWizard(BPListElement[] existingEntries,
+ BPListElement newEntry, boolean linkedMode,
+ boolean canCommitConflict, boolean allowConflict,
+ boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns,
+ IContainer parent) {
+ super(existingEntries, newEntry, getTitel(newEntry, linkedMode),
+ DLTKPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
+ fLinkedMode = linkedMode;
+ fCanCommitConflict = canCommitConflict;
+ fAllowConflict = allowConflict;
+ fAllowRemoveProjectFolder = allowRemoveProjectFolder;
+ fAllowAddExclusionPatterns = allowAddExclusionPatterns;
+ fParent = parent;
}
private static String getTitel(BPListElement newEntry, boolean linkedMode) {
if (newEntry.getPath() == null) {
if (linkedMode) {
return NewWizardMessages.NewSourceFolderCreationWizard_link_title;
- } else {
- return NewWizardMessages.NewSourceFolderCreationWizard_title;
}
- } else {
- return NewWizardMessages.NewSourceFolderCreationWizard_edit_title;
+ return NewWizardMessages.NewSourceFolderCreationWizard_title;
}
+ return NewWizardMessages.NewSourceFolderCreationWizard_edit_title;
}
@Override
public void addPages() {
super.addPages();
- fAddFolderPage= new AddSourceFolderWizardPage(getEntryToEdit(), getExistingEntries(),
- fLinkedMode, fCanCommitConflict,
- fAllowConflict, fAllowRemoveProjectFolder, fAllowAddExclusionPatterns, fParent);
+ fAddFolderPage = new AddSourceFolderWizardPage(getEntryToEdit(),
+ getExistingEntries(), fLinkedMode, fCanCommitConflict,
+ fAllowConflict, fAllowRemoveProjectFolder,
+ fAllowAddExclusionPatterns, fParent);
addPage(fAddFolderPage);
- fFilterPage= new SetFilterWizardPage(getEntryToEdit(), getExistingEntries());
+ fFilterPage = new SetFilterWizardPage(getEntryToEdit(),
+ getExistingEntries());
addPage(fFilterPage);
}
@Override
public List getInsertedElements() {
- List result= super.getInsertedElements();
+ List result = super.getInsertedElements();
if (getEntryToEdit().getOrginalPath() == null)
result.add(getEntryToEdit());
@@ -89,10 +97,12 @@ public class AddSourceFolderWizard extends BuildPathWizard {
@Override
public boolean performFinish() {
- getEntryToEdit().setAttribute(BPListElement.INCLUSION, fFilterPage.getInclusionPattern());
- getEntryToEdit().setAttribute(BPListElement.EXCLUSION, fFilterPage.getExclusionPattern());
+ getEntryToEdit().setAttribute(BPListElement.INCLUSION,
+ fFilterPage.getInclusionPattern());
+ getEntryToEdit().setAttribute(BPListElement.EXCLUSION,
+ fFilterPage.getExclusionPattern());
- boolean res= super.performFinish();
+ boolean res = super.performFinish();
if (res) {
selectAndReveal(fAddFolderPage.getCorrespondingResource());
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java
index 3b8a0fd3d..74f0ba06d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.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
@@ -215,10 +215,9 @@ public class BPListElement {
return DLTKCore.newBuiltinEntry(fPath, accesRules,
extraAttributes, new IPath[0],
BuildpathEntry.INCLUDE_ALL, isExported(), fExternal);
- } else {
- return DLTKCore.newLibraryEntry(fPath, accesRules,
- extraAttributes, isExported(), fExternal);
}
+ return DLTKCore.newLibraryEntry(fPath, accesRules, extraAttributes,
+ isExported(), fExternal);
}
case IBuildpathEntry.BPE_PROJECT: {
IAccessRule[] accesRules = (IAccessRule[]) getAttribute(
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java
index 95e1d8948..2c8146d1f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.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,8 +49,8 @@ public class BPListLabelProvider extends LabelProvider {
IWorkbench workbench = DLTKUIPlugin.getDefault().getWorkbench();
- fProjectImage = workbench.getSharedImages().getImageDescriptor(
- IDE.SharedImages.IMG_OBJ_PROJECT);
+ fProjectImage = workbench.getSharedImages()
+ .getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
}
@Override
@@ -62,23 +62,19 @@ public class BPListLabelProvider extends LabelProvider {
BPListElementAttribute attribute = (BPListElementAttribute) element;
String text = getCPListElementAttributeText(attribute);
if (attribute.isInNonModifiableContainer()) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_non_modifiable_attribute,
- text);
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_non_modifiable_attribute,
+ text);
}
return text;
} else if (element instanceof BPUserLibraryElement) {
return getCPUserLibraryText((BPUserLibraryElement) element);
} else if (element instanceof IAccessRule) {
IAccessRule rule = (IAccessRule) element;
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_access_rules_label,
- new String[] {
- AccessRulesLabelProvider
- .getResolutionLabel(rule.getKind()),
- rule.getPattern().toString() });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_access_rules_label,
+ AccessRulesLabelProvider.getResolutionLabel(rule.getKind()),
+ rule.getPattern().toString());
}
return super.getText(element);
}
@@ -107,8 +103,8 @@ public class BPListLabelProvider extends LabelProvider {
String pattern = patterns[i].toString();
if (pattern.length() > 0) {
if (patternsCount > 0) {
- buf
- .append(NewWizardMessages.CPListLabelProvider_exclusion_filter_separator);
+ buf.append(
+ NewWizardMessages.CPListLabelProvider_exclusion_filter_separator);
}
buf.append(pattern);
patternsCount++;
@@ -122,10 +118,9 @@ public class BPListLabelProvider extends LabelProvider {
} else {
arg = notAvailable;
}
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_exclusion_filter_label,
- new String[] { arg });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_exclusion_filter_label,
+ arg);
} else if (key.equals(BPListElement.INCLUSION)) {
String arg = null;
IPath[] patterns = (IPath[]) attrib.getValue();
@@ -136,8 +131,8 @@ public class BPListLabelProvider extends LabelProvider {
String pattern = patterns[i].toString();
if (pattern.length() > 0) {
if (patternsCount > 0) {
- buf
- .append(NewWizardMessages.CPListLabelProvider_inclusion_filter_separator);
+ buf.append(
+ NewWizardMessages.CPListLabelProvider_inclusion_filter_separator);
}
buf.append(pattern);
patternsCount++;
@@ -151,51 +146,42 @@ public class BPListLabelProvider extends LabelProvider {
} else {
arg = NewWizardMessages.CPListLabelProvider_all;
}
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_inclusion_filter_label,
- new String[] { arg });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_inclusion_filter_label,
+ arg);
} else if (key.equals(BPListElement.ACCESSRULES)) {
IAccessRule[] rules = (IAccessRule[]) attrib.getValue();
int nRules = rules != null ? rules.length : 0;
int parentKind = attrib.getParent().getEntryKind();
if (parentKind == IBuildpathEntry.BPE_PROJECT) {
- Boolean combined = (Boolean) attrib.getParent().getAttribute(
- BPListElement.COMBINE_ACCESSRULES);
+ Boolean combined = (Boolean) attrib.getParent()
+ .getAttribute(BPListElement.COMBINE_ACCESSRULES);
if (nRules > 0) {
if (combined.booleanValue()) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_project_access_rules_combined,
- String.valueOf(nRules));
- } else {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_project_access_rules_not_combined,
- String.valueOf(nRules));
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_project_access_rules_combined,
+ String.valueOf(nRules));
}
- } else {
- return NewWizardMessages.CPListLabelProvider_project_access_rules_no_rules;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_project_access_rules_not_combined,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_project_access_rules_no_rules;
} else if (parentKind == IBuildpathEntry.BPE_CONTAINER) {
if (nRules > 0) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_container_access_rules,
- String.valueOf(nRules));
- } else {
- return NewWizardMessages.CPListLabelProvider_container_no_access_rules;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_container_access_rules,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_container_no_access_rules;
} else {
if (nRules > 0) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_access_rules_enabled,
- String.valueOf(nRules));
- } else {
- return NewWizardMessages.CPListLabelProvider_access_rules_disabled;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_access_rules_enabled,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_access_rules_disabled;
}
}
if (DLTKCore.DEBUG) {
@@ -217,8 +203,8 @@ public class BPListLabelProvider extends LabelProvider {
public String getCPListElementText(BPListElement cpentry) {
IPath path = cpentry.getPath();
- if (path.toString().startsWith(
- IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
+ if (path.toString()
+ .startsWith(IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
return ScriptElementLabels.BUILTINS_FRAGMENT;
}
if (EnvironmentPathUtils.isFull(path)) {
@@ -228,8 +214,8 @@ public class BPListLabelProvider extends LabelProvider {
case IBuildpathEntry.BPE_LIBRARY: {
IResource resource = cpentry.getResource();
if (resource instanceof IContainer) {
- StringBuffer buf = new StringBuffer(path.makeRelative()
- .toString());
+ StringBuffer buf = new StringBuffer(
+ path.makeRelative().toString());
IPath linkTarget = cpentry.getLinkTarget();
if (linkTarget != null) {
buf.append(ScriptElementLabels.CONCAT_STRING);
@@ -252,9 +238,8 @@ public class BPListLabelProvider extends LabelProvider {
// should not get here
if (!cpentry.isExternalFolder()) {
return path.makeRelative().toString();
- } else {
- return path.toString();
}
+ return path.toString();
}
case IBuildpathEntry.BPE_PROJECT:
return path.lastSegment();
@@ -270,10 +255,9 @@ public class BPListLabelProvider extends LabelProvider {
if (initializer != null) {
String description = initializer.getDescription(path,
cpentry.getScriptProject());
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_unbound_library,
- description);
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_unbound_library,
+ description);
}
} catch (ModelException e) {
@@ -314,11 +298,9 @@ public class BPListLabelProvider extends LabelProvider {
: appendedPath.makeRelative().toString();
return Messages.format(
NewWizardMessages.CPListLabelProvider_twopart,
- new String[] { path.lastSegment(), appended });
- } else {
- return isExternal ? path.toOSString() : path.makeRelative()
- .toString();
+ path.lastSegment(), appended);
}
+ return isExternal ? path.toOSString() : path.makeRelative().toString();
}
protected ImageDescriptor getCPListElementBaseImage(BPListElement cpentry) {
@@ -327,10 +309,9 @@ public class BPListLabelProvider extends LabelProvider {
case IBuildpathEntry.BPE_SOURCE:
if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage;
- } else {
- return DLTKPluginImages
- .getDescriptor(DLTKPluginImages.IMG_OBJS_PACKFRAG_ROOT);
}
+ return DLTKPluginImages
+ .getDescriptor(DLTKPluginImages.IMG_OBJS_PACKFRAG_ROOT);
case IBuildpathEntry.BPE_LIBRARY:
return DLTKPluginImages
.getDescriptor(DLTKPluginImages.IMG_OBJS_EXTZIP_WSRC);
@@ -349,7 +330,8 @@ public class BPListLabelProvider extends LabelProvider {
if (element instanceof BPListElement) {
BPListElement cpentry = (BPListElement) element;
- ImageDescriptor imageDescriptor = getCPListElementBaseImage(cpentry);
+ ImageDescriptor imageDescriptor = getCPListElementBaseImage(
+ cpentry);
if (imageDescriptor != null) {
if (cpentry.isMissing()) {
imageDescriptor = new ScriptElementImageDescriptor(
@@ -362,11 +344,11 @@ public class BPListLabelProvider extends LabelProvider {
} else if (element instanceof BPListElementAttribute) {
String key = ((BPListElementAttribute) element).getKey();
if (key.equals(BPListElement.EXCLUSION)) {
- return fRegistry
- .get(DLTKPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB);
+ return fRegistry.get(
+ DLTKPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB);
} else if (key.equals(BPListElement.INCLUSION)) {
- return fRegistry
- .get(DLTKPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB);
+ return fRegistry.get(
+ DLTKPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB);
} else if (key.equals(BPListElement.ACCESSRULES)) {
return fRegistry
.get(DLTKPluginImages.DESC_OBJS_ACCESSRULES_ATTRIB);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java
index a859d2d8e..c5c5e955e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.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
@@ -42,13 +42,13 @@ import org.eclipse.ui.INewWizard;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-
public class CreateMultipleSourceFoldersDialog extends TrayDialog {
- private final class FakeFolderBaseWorkbenchContentProvider extends BaseWorkbenchContentProvider {
+ private final class FakeFolderBaseWorkbenchContentProvider
+ extends BaseWorkbenchContentProvider {
@Override
public Object getParent(Object element) {
- Object object= fNonExistingFolders.get(element);
+ Object object = fNonExistingFolders.get(element);
if (object != null)
return object;
@@ -57,11 +57,11 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
@Override
public Object[] getChildren(Object element) {
- List result= new ArrayList();
- //all keys with value element
- Set keys= fNonExistingFolders.keySet();
- for (Iterator iter= keys.iterator(); iter.hasNext();) {
- Object key= iter.next();
+ List result = new ArrayList();
+ // all keys with value element
+ Set keys = fNonExistingFolders.keySet();
+ for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ Object key = iter.next();
if (fNonExistingFolders.get(key).equals(element)) {
result.add(key);
}
@@ -69,8 +69,8 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
if (result.size() == 0)
return super.getChildren(element);
- Object[] children= super.getChildren(element);
- for (int i= 0; i < children.length; i++) {
+ Object[] children = super.getChildren(element);
+ for (int i = 0; i < children.length; i++) {
result.add(children[i]);
}
return result.toArray();
@@ -84,17 +84,18 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
private final HashSet fInsertedElements;
private final Hashtable fNonExistingFolders;
- public CreateMultipleSourceFoldersDialog(final IScriptProject scriptProject, final BPListElement[] existingElements, Shell shell) {
+ public CreateMultipleSourceFoldersDialog(final IScriptProject scriptProject,
+ final BPListElement[] existingElements, Shell shell) {
super(shell);
- fScriptProject= scriptProject;
- fExistingElements= existingElements;
- fRemovedElements= new HashSet();
- fModifiedElements= new HashSet();
- fInsertedElements= new HashSet();
- fNonExistingFolders= new Hashtable();
-
- for (int i= 0; i < existingElements.length; i++) {
- BPListElement cur= existingElements[i];
+ fScriptProject = scriptProject;
+ fExistingElements = existingElements;
+ fRemovedElements = new HashSet();
+ fModifiedElements = new HashSet();
+ fInsertedElements = new HashSet();
+ fNonExistingFolders = new Hashtable();
+
+ for (int i = 0; i < existingElements.length; i++) {
+ BPListElement cur = existingElements[i];
if (cur.getResource() == null || !cur.getResource().exists()) {
addFakeFolder(fScriptProject.getProject(), cur);
}
@@ -103,43 +104,49 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
@Override
public int open() {
- Class[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
- List existingContainers= getExistingContainers(fExistingElements);
+ Class[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
+ List existingContainers = getExistingContainers(fExistingElements);
- IProject[] allProjects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList rejectedElements= new ArrayList(allProjects.length);
- IProject currProject= fScriptProject.getProject();
- for (int i= 0; i < allProjects.length; i++) {
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ ArrayList rejectedElements = new ArrayList(allProjects.length);
+ IProject currProject = fScriptProject.getProject();
+ for (int i = 0; i < allProjects.length; i++) {
if (!allProjects[i].equals(currProject)) {
rejectedElements.add(allProjects[i]);
}
}
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
-
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new FakeFolderBaseWorkbenchContentProvider();
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses,
+ rejectedElements.toArray());
- String title= NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_new_title;
- String message= NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_edit_description;
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new FakeFolderBaseWorkbenchContentProvider();
+ String title = NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_new_title;
+ String message = NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_edit_description;
- MultipleFolderSelectionDialog dialog= new MultipleFolderSelectionDialog(getShell(), lp, cp) {
+ MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(
+ getShell(), lp, cp) {
@Override
protected Control createDialogArea(Composite parent) {
- Control result= super.createDialogArea(parent);
+ Control result = super.createDialogArea(parent);
if (DLTKCore.DEBUG) {
- System.err.println("CreateMultipleSourceFoldersDialog: Add help support"); //$NON-NLS-1$
+ System.err.println(
+ "CreateMultipleSourceFoldersDialog: Add help support"); //$NON-NLS-1$
}
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDLTKHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
+ // IDLTKHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
return result;
}
@Override
protected Object createFolder(final IContainer container) {
- final Object[] result= new Object[1];
- final BPListElement newElement= new BPListElement(fScriptProject, IBuildpathEntry.BPE_SOURCE, false);
- final AddSourceFolderWizard wizard= newSourceFolderWizard(newElement, fExistingElements, container);
- AbstractOpenWizardAction action= new AbstractOpenWizardAction() {
+ final Object[] result = new Object[1];
+ final BPListElement newElement = new BPListElement(
+ fScriptProject, IBuildpathEntry.BPE_SOURCE, false);
+ final AddSourceFolderWizard wizard = newSourceFolderWizard(
+ newElement, fExistingElements, container);
+ AbstractOpenWizardAction action = new AbstractOpenWizardAction() {
@Override
protected INewWizard createWizard() throws CoreException {
return wizard;
@@ -148,7 +155,8 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
action.addPropertyChangeListener(event -> {
if (event.getProperty().equals(IAction.RESULT)) {
if (event.getNewValue().equals(Boolean.TRUE)) {
- result[0]= addFakeFolder(fScriptProject.getProject(), newElement);
+ result[0] = addFakeFolder(
+ fScriptProject.getProject(), newElement);
} else {
wizard.cancel();
}
@@ -166,23 +174,24 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
dialog.setInitialFocus(fScriptProject.getProject());
if (dialog.open() == Window.OK) {
- Object[] elements= dialog.getResult();
- for (int i= 0; i < elements.length; i++) {
- IResource res= (IResource)elements[i];
- fInsertedElements.add(new BPListElement(fScriptProject, IBuildpathEntry.BPE_SOURCE, res.getFullPath(), res, false));
+ Object[] elements = dialog.getResult();
+ for (int i = 0; i < elements.length; i++) {
+ IResource res = (IResource) elements[i];
+ fInsertedElements.add(new BPListElement(fScriptProject,
+ IBuildpathEntry.BPE_SOURCE, res.getFullPath(), res,
+ false));
}
if (fExistingElements.length == 1) {
} else {
- ArrayList added= new ArrayList(fInsertedElements);
- HashSet updatedEclusionPatterns= new HashSet();
+ ArrayList added = new ArrayList(fInsertedElements);
+ HashSet updatedEclusionPatterns = new HashSet();
addExlusionPatterns(added, updatedEclusionPatterns);
fModifiedElements.addAll(updatedEclusionPatterns);
}
return Window.OK;
- } else {
- return Window.CANCEL;
}
+ return Window.CANCEL;
}
public List getInsertedElements() {
@@ -203,50 +212,53 @@ public class CreateMultipleSourceFoldersDialog extends TrayDialog {
newEntries.toArray(new BPListElement[newEntries.size()]),
fExistingElements, modifiedEntries);
if (!modifiedEntries.isEmpty()) {
- String title= NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_title;
- String message= NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_message;
+ String title = NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_title;
+ String message = NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_message;
MessageDialog.openInformation(getShell(), title, message);
}
}
- private AddSourceFolderWizard newSourceFolderWizard(BPListElement element, BPListElement[] existing, IContainer parent) {
- AddSourceFolderWizard wizard= new AddSourceFolderWizard(existing, element, false, true, false, false, false, parent);
+ private AddSourceFolderWizard newSourceFolderWizard(BPListElement element,
+ BPListElement[] existing, IContainer parent) {
+ AddSourceFolderWizard wizard = new AddSourceFolderWizard(existing,
+ element, false, true, false, false, false, parent);
wizard.setDoFlushChange(false);
return wizard;
}
private List getExistingContainers(BPListElement[] existingElements) {
- List res= new ArrayList();
- for (int i= 0; i < existingElements.length; i++) {
- IResource resource= existingElements[i].getResource();
+ List res = new ArrayList();
+ for (int i = 0; i < existingElements.length; i++) {
+ IResource resource = existingElements[i].getResource();
if (resource instanceof IContainer) {
res.add(resource);
}
}
- Set keys= fNonExistingFolders.keySet();
- for (Iterator iter= keys.iterator(); iter.hasNext();) {
- IFolder folder= (IFolder)iter.next();
+ Set keys = fNonExistingFolders.keySet();
+ for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ IFolder folder = (IFolder) iter.next();
res.add(folder);
}
return res;
}
- private IFolder addFakeFolder(final IContainer container, final BPListElement element) {
+ private IFolder addFakeFolder(final IContainer container,
+ final BPListElement element) {
IFolder result;
- IPath projectPath= fScriptProject.getPath();
- IPath path= element.getPath();
+ IPath projectPath = fScriptProject.getPath();
+ IPath path = element.getPath();
if (projectPath.isPrefixOf(path)) {
- path= path.removeFirstSegments(projectPath.segmentCount());
+ path = path.removeFirstSegments(projectPath.segmentCount());
}
- result= container.getFolder(path);
- IFolder folder= result;
+ result = container.getFolder(path);
+ IFolder folder = result;
do {
- IContainer parent= folder.getParent();
+ IContainer parent = folder.getParent();
fNonExistingFolders.put(folder, parent);
if (parent instanceof IFolder) {
- folder= (IFolder)parent;
+ folder = (IFolder) parent;
} else {
- folder= null;
+ folder = null;
}
} while (folder != null && !folder.exists());
return result;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
index e050034fc..515e1ff33 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.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
@@ -83,9 +83,9 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* used.
*
* @param selection
- * the current selection
+ * the current selection
* @param jProject
- * the element's script project
+ * the element's script project
*/
public DialogExplorerActionContext(ISelection selection,
IScriptProject jProject) {
@@ -106,9 +106,9 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* used.
*
* @param selectedElements
- * a list of currently selected elements
+ * a list of currently selected elements
* @param jProject
- * the element's script project
+ * the element's script project
*/
public DialogExplorerActionContext(List selectedElements,
IScriptProject jProject) {
@@ -178,11 +178,12 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* actions.
*
* @param provider
- * a information provider to pass necessary information to the
- * operations
+ * a information provider to pass necessary information
+ * to the operations
* @param listener
- * a listener for the changes on Buildpath entries, that is the
- * listener will be notified whenever a Buildpath entry changed.
+ * a listener for the changes on Buildpath entries, that
+ * is the listener will be notified whenever a Buildpath
+ * entry changed.
* @see IBuildpathModifierListener
*/
public DialogPackageExplorerActionGroup(
@@ -274,8 +275,8 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Get an action of the specified type
*
* @param type
- * the type of the desired action, must be a constante of
- * <code>IBuildpathInformationProvider</code>
+ * the type of the desired action, must be a constante of
+ * <code>IBuildpathInformationProvider</code>
* @return the requested action
*
* @see IBuildpathInformationProvider
@@ -309,7 +310,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Create a toolbar manager for a given <code>ViewerPane</code>
*
* @param pane
- * the pane to create the <code>
+ * the pane to create the <code>
* ToolBarManager</code> for.
* @return the created <code>ToolBarManager</code>
*/
@@ -328,7 +329,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Create a toolbar manager for a given <code>ViewerPane</code>
*
* @param pane
- * the pane to create the help toolbar for
+ * the pane to create the help toolbar for
* @return the created <code>ToolBarManager</code>
*/
public ToolBarManager createLeftToolBar(ViewerPane pane) {
@@ -397,7 +398,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* can be called.
*
* @param context
- * the action context
+ * the action context
*
* @see IPackageExplorerActionListener
* @see PackageExplorerActionEvent
@@ -406,7 +407,8 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* @see #refresh(DialogExplorerActionContext)
*
* @throws ModelException
- * if there is a failure while computing the available actions.
+ * if there is a failure while computing the
+ * available actions.
*/
public void setContext(DialogExplorerActionContext context)
throws ModelException {
@@ -455,11 +457,11 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Internal method to set the context of the action group.
*
* @param selectedElements
- * a list of selected elements, can be empty
+ * a list of selected elements, can be empty
* @param project
- * the script project
+ * the script project
* @param type
- * the type of the selected element(s)
+ * the type of the selected element(s)
* @throws ModelException
*/
private void internalSetContext(List selectedElements,
@@ -490,9 +492,9 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* therefore provides more information.
*
* @param elements
- * a list of elements to be compared to each other
+ * a list of elements to be compared to each other
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if all elements are of the same type,
* <code>false</code> otherwise.
* @throws ModelException
@@ -516,11 +518,11 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Inform all listeners about new actions.
*
* @param descriptions
- * an array of descriptions for each actions, where the
- * description at position 'i' belongs to the action at position
- * 'i'
+ * an array of descriptions for each actions, where
+ * the description at position 'i' belongs to the
+ * action at position 'i'
* @param actions
- * an array of available actions
+ * an array of available actions
*/
private void informListeners(String[] descriptions,
BuildpathModifierAction[] actions) {
@@ -575,7 +577,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* to set the content of the hint text group properly.
*
* @param obj
- * the object to get the type from
+ * the object to get the type from
* @return the type of the current selection or UNDEFINED if no appropriate
* type could be found. Possible types are:<br>
* PackageExplorerActionGroup.FOLDER<br>
@@ -648,7 +650,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Get the type of the folder
*
* @param folder
- * folder to get the type from
+ * folder to get the type from
* @return the type code for the folder. Possible types are:<br>
* PackageExplorerActionGroup.FOLDER<br>
* PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
@@ -674,7 +676,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Get the type of the file
*
* @param file
- * file to get the type from
+ * file to get the type from
* @return the type code for the file. Possible types are:<br>
* PackageExplorerActionGroup.EXCLUDED_FILE<br>
* PackageExplorerActionGroup.FILE
@@ -717,9 +719,9 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* that can be applied on this elements
*
* @param selectedElements
- * the list of elements to get the actions for
+ * the list of elements to get the actions for
* @param project
- * the script project
+ * the script project
* @return a list of <code>BuildpathModifierAction</code>s
* @throws ModelException
*/
@@ -757,12 +759,12 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Changes the enabled state of an action if necessary.
*
* @param action
- * the action to change it's state for
+ * the action to change it's state for
* @param selectedElements
- * a list of selected elements
+ * a list of selected elements
* @param types
- * an array of types corresponding to the types of the selected
- * elements
+ * an array of types corresponding to the types
+ * of the selected elements
* @return <code>true</code> if the action is valid (= enabled),
* <code>false</code> otherwise
* @throws ModelException
@@ -773,18 +775,17 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
if (!action.isEnabled())
action.setEnabled(true);
return true;
- } else {
- if (action.isEnabled())
- action.setEnabled(false);
- return false;
}
+ if (action.isEnabled())
+ action.setEnabled(false);
+ return false;
}
/**
* Fill the context menu with the available actions
*
* @param menu
- * the menu to be filled up with actions
+ * the menu to be filled up with actions
*/
@Override
public void fillContextMenu(IMenuManager menu) {
@@ -809,7 +810,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Add listeners for the <code>PackageExplorerActionEvent</code>.
*
* @param listener
- * the listener to be added
+ * the listener to be added
*
* @see PackageExplorerActionEvent
* @see IPackageExplorerActionListener
@@ -822,7 +823,7 @@ public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
* Remove the listener from the list of registered listeners.
*
* @param listener
- * the listener to be removed
+ * the listener to be removed
*/
public void removeListener(IPackageExplorerActionListener listener) {
fListeners.remove(listener);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
index 8042d6138..bfc4348a3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.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
@@ -39,38 +39,38 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
/**
* Creates a group without border.
*/
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
+ public SelectionButtonDialogFieldGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns) {
this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
}
-
/**
- * Creates a group with border (label in border).
- * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
- * For border styles see <code>Group</code>
+ * Creates a group with border (label in border). Accepted button styles
+ * are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see
+ * <code>Group</code>
*/
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
+ public SelectionButtonDialogFieldGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns, int borderStyle) {
super();
- Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
- fButtonsStyle= buttonsStyle;
-
- int nButtons= buttonNames.length;
- fButtonsSelected= new boolean[nButtons];
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsSelected[i]= false;
- fButtonsEnabled[i]= true;
+ Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK
+ || buttonsStyle == SWT.TOGGLE);
+ fButtonNames = buttonNames;
+ fButtonsStyle = buttonsStyle;
+
+ int nButtons = buttonNames.length;
+ fButtonsSelected = new boolean[nButtons];
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsSelected[i] = false;
+ fButtonsEnabled[i] = true;
}
if (buttonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
+ fButtonsSelected[0] = true;
}
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
-
+ fGroupBorderStyle = borderStyle;
+ fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
}
@@ -81,23 +81,22 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
assertEnoughColumns(nColumns);
if (fGroupBorderStyle == SWT.NONE) {
- Label label= getLabelControl(parent);
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns - 1;
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns - 1;
buttonsgroup.setLayoutData(gd);
return new Control[] { label, buttonsgroup };
- } else {
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- buttonsgroup.setLayoutData(gd);
-
- return new Control[] { buttonsgroup };
}
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
+ buttonsgroup.setLayoutData(gd);
+
+ return new Control[] { buttonsgroup };
}
@Override
@@ -107,8 +106,9 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
// ------- ui creation
- private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
+ private Button createSelectionButton(int index, Composite group,
+ SelectionListener listener) {
+ Button button = new Button(group, fButtonsStyle | SWT.LEFT);
button.setFont(group.getFont());
button.setText(fButtonNames[index]);
button.setEnabled(isEnabled() && fButtonsEnabled[index]);
@@ -119,52 +119,57 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
/**
- * Returns the group widget. When called the first time, the widget will be created.
- * @param parent The parent composite when called the first time, or <code>null</code>
- * after.
+ * Returns the group widget. When called the first time, the widget will be
+ * created.
+ *
+ * @param parent
+ * The parent composite when called the first time, or
+ * <code>null</code> after.
*/
public Composite getSelectionButtonsGroup(Composite parent) {
if (fButtonComposite == null) {
assertCompositeNotNull(parent);
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= fGroupNumberOfColumns;
+ GridLayout layout = new GridLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = fGroupNumberOfColumns;
if (fGroupBorderStyle != SWT.NONE) {
- Group group= new Group(parent, fGroupBorderStyle);
+ Group group = new Group(parent, fGroupBorderStyle);
group.setFont(parent.getFont());
if (fLabelText != null && fLabelText.length() > 0) {
group.setText(fLabelText);
}
- fButtonComposite= group;
+ fButtonComposite = group;
} else {
- fButtonComposite= new Composite(parent, SWT.NONE);
+ fButtonComposite = new Composite(parent, SWT.NONE);
fButtonComposite.setFont(parent.getFont());
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
}
fButtonComposite.setLayout(layout);
- SelectionListener listener= new SelectionListener() {
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
};
- int nButtons= fButtonNames.length;
- fButtons= new Button[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+ int nButtons = fButtonNames.length;
+ fButtons = new Button[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtons[i] = createSelectionButton(i, fButtonComposite,
+ listener);
}
- int nRows= nButtons / fGroupNumberOfColumns;
- int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
- for (int i= 0; i < nFillElements; i++) {
+ int nRows = nButtons / fGroupNumberOfColumns;
+ int nFillElements = nRows * fGroupNumberOfColumns - nButtons;
+ for (int i = 0; i < nFillElements; i++) {
createEmptySpace(fButtonComposite);
}
}
@@ -182,10 +187,10 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
private void doWidgetSelected(SelectionEvent e) {
- Button button= (Button)e.widget;
- for (int i= 0; i < fButtons.length; i++) {
+ Button button = (Button) e.widget;
+ for (int i = 0; i < fButtons.length; i++) {
if (fButtons[i] == button) {
- fButtonsSelected[i]= button.getSelection();
+ fButtonsSelected[i] = button.getSelection();
dialogFieldChanged();
return;
}
@@ -196,7 +201,9 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
/**
* Returns the selection state of a button contained in the group.
- * @param index The index of the button
+ *
+ * @param index
+ * The index of the button
*/
public boolean isSelected(int index) {
if (index >= 0 && index < fButtonsSelected.length) {
@@ -211,9 +218,9 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
public void setSelection(int index, boolean selected) {
if (index >= 0 && index < fButtonsSelected.length) {
if (fButtonsSelected[index] != selected) {
- fButtonsSelected[index]= selected;
+ fButtonsSelected[index] = selected;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setSelection(selected);
}
@@ -228,9 +235,9 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
protected void updateEnableState() {
super.updateEnableState();
if (fButtons != null) {
- boolean enabled= isEnabled();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ boolean enabled = isEnabled();
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setEnabled(enabled && fButtonsEnabled[i]);
}
@@ -243,9 +250,9 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
*/
public void enableSelectionButton(int index, boolean enable) {
if (index >= 0 && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
+ fButtonsEnabled[index] = enable;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setEnabled(isEnabled() && enable);
}
@@ -256,8 +263,8 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
@Override
public void refresh() {
super.refresh();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setSelection(fButtonsSelected[i]);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java
index 998ed2a72..afe134317 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.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
@@ -22,7 +22,8 @@ import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.IWorkingSetPage;
-public abstract class AbstractWorkingSetWizardPage extends WizardPage implements IWorkingSetPage {
+public abstract class AbstractWorkingSetWizardPage extends WizardPage
+ implements IWorkingSetPage {
private boolean fIsFirstValidation;
private Text fWorkingSetName;
@@ -31,7 +32,8 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
/**
* Default constructor.
*/
- public AbstractWorkingSetWizardPage(String pageid, String title, ImageDescriptor image) {
+ public AbstractWorkingSetWizardPage(String pageid, String title,
+ ImageDescriptor image) {
super(pageid, title, image);
}
@@ -39,21 +41,23 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
public void createControl(Composite parent) {
initializeDialogUnits(parent);
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
setControl(composite);
- Label label= new Label(composite, SWT.WRAP);
- label.setText(WorkingSetMessages.AbstractWorkingSetPage_workingSet_name);
- GridData gd= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText(
+ WorkingSetMessages.AbstractWorkingSetPage_workingSet_name);
+ GridData gd = new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
- fWorkingSetName= new Text(composite, SWT.SINGLE | SWT.BORDER);
- fWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- fWorkingSetName.addModifyListener(
- e -> validateInput()
- );
+ fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ fWorkingSetName.setLayoutData(new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ fWorkingSetName.addModifyListener(e -> validateInput());
fWorkingSetName.setFocus();
Dialog.applyDialogFont(composite);
@@ -67,8 +71,9 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
@Override
public void setSelection(IWorkingSet workingSet) {
Assert.isNotNull(workingSet, "Working set must not be null"); //$NON-NLS-1$
- fWorkingSet= workingSet;
- if (getContainer() != null && getShell() != null && fWorkingSetName != null) {
+ fWorkingSet = workingSet;
+ if (getContainer() != null && getShell() != null
+ && fWorkingSetName != null) {
fWorkingSetName.setText(fWorkingSet.getName());
validateInput();
}
@@ -76,9 +81,9 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
@Override
public void finish() {
- String workingSetName= fWorkingSetName.getText();
+ String workingSetName = fWorkingSetName.getText();
if (fWorkingSet == null) {
- fWorkingSet= createWorkingSet(workingSetName);
+ fWorkingSet = createWorkingSet(workingSetName);
}
fWorkingSet.setName(workingSetName);
}
@@ -86,28 +91,29 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
protected abstract IWorkingSet createWorkingSet(String workingSetName);
private void validateInput() {
- String errorMessage= null;
- String newText= fWorkingSetName.getText();
+ String errorMessage = null;
+ String newText = fWorkingSetName.getText();
if (newText.equals(newText.trim()) == false)
errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_nameWhitespace;
if (newText.equals("")) { //$NON-NLS-1$
if (fIsFirstValidation) {
setPageComplete(false);
- fIsFirstValidation= false;
+ fIsFirstValidation = false;
return;
- } else {
- errorMessage= WorkingSetMessages.AbstractWorkingSetPage_warning_nameMustNotBeEmpty;
}
+ errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_nameMustNotBeEmpty;
}
- fIsFirstValidation= false;
+ fIsFirstValidation = false;
- if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
- IWorkingSet[] workingSets= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
- for (int i= 0; i < workingSets.length; i++) {
+ if (errorMessage == null && (fWorkingSet == null
+ || newText.equals(fWorkingSet.getName()) == false)) {
+ IWorkingSet[] workingSets = PlatformUI.getWorkbench()
+ .getWorkingSetManager().getWorkingSets();
+ for (int i = 0; i < workingSets.length; i++) {
if (newText.equals(workingSets[i].getName())) {
- errorMessage= WorkingSetMessages.AbstractWorkingSetPage_warning_workingSetExists;
+ errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_workingSetExists;
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java
index 74e2bcbf5..8452bc4da 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.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
@@ -36,16 +36,19 @@ import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDEActionFactory;
+public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
+ implements IResourceChangeListener {
-public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction implements IResourceChangeListener {
-
- private static final class CloseWorkingSetAction extends OpenCloseWorkingSetAction {
+ private static final class CloseWorkingSetAction
+ extends OpenCloseWorkingSetAction {
private IAction fProjectAction;
+
private CloseWorkingSetAction(IWorkbenchSite site, String label) {
super(site, label);
- IActionBars actionBars= getActionBars();
+ IActionBars actionBars = getActionBars();
if (actionBars != null) {
- fProjectAction= actionBars.getGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId());
+ fProjectAction = actionBars.getGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId());
}
}
@@ -55,19 +58,22 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
}
@Override
- protected void performOperation(IProject project, IProgressMonitor monitor) throws CoreException {
+ protected void performOperation(IProject project,
+ IProgressMonitor monitor) throws CoreException {
project.close(monitor);
}
@Override
protected void connectToActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), this);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId(), this);
actionBars.updateActionBars();
}
@Override
protected void disconnectFromActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), fProjectAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId(), fProjectAction);
actionBars.updateActionBars();
}
@@ -82,13 +88,16 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
}
}
- private static final class OpenWorkingSetAction extends OpenCloseWorkingSetAction {
+ private static final class OpenWorkingSetAction
+ extends OpenCloseWorkingSetAction {
private IAction fProjectAction;
+
private OpenWorkingSetAction(IWorkbenchSite site, String label) {
super(site, label);
- IActionBars actionBars= getActionBars();
+ IActionBars actionBars = getActionBars();
if (actionBars != null) {
- fProjectAction= actionBars.getGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId());
+ fProjectAction = actionBars.getGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId());
}
}
@@ -98,19 +107,22 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
}
@Override
- protected void performOperation(IProject project, IProgressMonitor monitor) throws CoreException {
+ protected void performOperation(IProject project,
+ IProgressMonitor monitor) throws CoreException {
project.open(monitor);
}
@Override
protected void connectToActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), this);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId(), this);
actionBars.updateActionBars();
}
@Override
protected void disconnectFromActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), fProjectAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId(), fProjectAction);
actionBars.updateActionBars();
}
@@ -128,15 +140,20 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
private OpenCloseWorkingSetAction(IWorkbenchSite site, String label) {
super(site);
setText(label);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
+ IResourceChangeEvent.POST_CHANGE);
}
- public static OpenCloseWorkingSetAction createCloseAction(IWorkbenchSite site) {
- return new CloseWorkingSetAction(site, WorkingSetMessages.OpenCloseWorkingSetAction_close_label);
+ public static OpenCloseWorkingSetAction createCloseAction(
+ IWorkbenchSite site) {
+ return new CloseWorkingSetAction(site,
+ WorkingSetMessages.OpenCloseWorkingSetAction_close_label);
}
- public static OpenCloseWorkingSetAction createOpenAction(IWorkbenchSite site) {
- return new OpenWorkingSetAction(site, WorkingSetMessages.OpenCloseWorkingSetAction_open_label);
+ public static OpenCloseWorkingSetAction createOpenAction(
+ IWorkbenchSite site) {
+ return new OpenWorkingSetAction(site,
+ WorkingSetMessages.OpenCloseWorkingSetAction_open_label);
}
public void dispose() {
@@ -145,8 +162,8 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
@Override
public void selectionChanged(IStructuredSelection selection) {
- List projects= getProjects(selection);
- IActionBars actionBars= getActionBars();
+ List projects = getProjects(selection);
+ IActionBars actionBars = getActionBars();
if (projects != null && projects.size() > 0) {
setEnabled(true);
if (actionBars != null) {
@@ -162,7 +179,7 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
@Override
public void run(IStructuredSelection selection) {
- final List projects= getProjects(selection);
+ final List projects = getProjects(selection);
if (projects != null && projects.size() > 0) {
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
@@ -173,11 +190,12 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
IProject project = (IProject) iter.next();
performOperation(project,
new SubProgressMonitor(monitor, 1));
- }
+ }
monitor.done();
- }));
+ }));
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), getErrorTitle(), getErrorMessage());
+ ExceptionHandler.handle(e, getShell(), getErrorTitle(),
+ getErrorMessage());
} catch (InterruptedException e) {
// do nothing. Got cancelled.
}
@@ -186,7 +204,8 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
protected abstract boolean validate(IProject project);
- protected abstract void performOperation(IProject project, IProgressMonitor monitor) throws CoreException;
+ protected abstract void performOperation(IProject project,
+ IProgressMonitor monitor) throws CoreException;
protected abstract void connectToActionBar(IActionBars actionBars);
@@ -197,13 +216,13 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
protected abstract String getErrorMessage();
private List getProjects(IStructuredSelection selection) {
- List result= new ArrayList();
- List elements= selection.toList();
- for (Iterator iter= elements.iterator(); iter.hasNext();) {
- Object element= iter.next();
+ List result = new ArrayList();
+ List elements = selection.toList();
+ for (Iterator iter = elements.iterator(); iter.hasNext();) {
+ Object element = iter.next();
if (!(element instanceof IWorkingSet))
return null;
- List projects= getProjects((IWorkingSet)element);
+ List projects = getProjects((IWorkingSet) element);
if (projects == null)
return null;
result.addAll(projects);
@@ -212,15 +231,15 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
}
private List getProjects(IWorkingSet set) {
- List result= new ArrayList();
- IAdaptable[] elements= set.getElements();
- for (int i= 0; i < elements.length; i++) {
- Object element= elements[i];
- IProject project= null;
+ List result = new ArrayList();
+ IAdaptable[] elements = set.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ Object element = elements[i];
+ IProject project = null;
if (element instanceof IProject) {
- project= (IProject)element;
+ project = (IProject) element;
} else if (element instanceof IScriptProject) {
- project= ((IScriptProject)element).getProject();
+ project = ((IScriptProject) element).getProject();
}
if (project != null && validate(project))
result.add(project);
@@ -230,24 +249,21 @@ public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
protected IActionBars getActionBars() {
if (getSite() instanceof IViewSite) {
- return ((IViewSite)getSite()).getActionBars();
- } else {
- return null;
+ return ((IViewSite) getSite()).getActionBars();
}
+ return null;
}
- /**
- * {@inheritDoc}
- */
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
if (delta != null) {
- IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
+ IResourceDelta[] projDeltas = delta
+ .getAffectedChildren(IResourceDelta.CHANGED);
for (int i = 0; i < projDeltas.length; ++i) {
IResourceDelta projDelta = projDeltas[i];
if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) {
- Shell shell= getShell();
+ Shell shell = getShell();
if (!shell.isDisposed()) {
shell.getDisplay()
.asyncExec(() -> update(getSelection()));
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/ScriptWorkingSetPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/ScriptWorkingSetPage.java
index 2ff4991e2..cda3d5885 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/ScriptWorkingSetPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/ScriptWorkingSetPage.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
@@ -64,8 +64,6 @@ import org.eclipse.ui.dialogs.IWorkingSetPage;
* <p>
* Working set elements are presented as a Script element tree.
* </p>
- *
- *
*/
public class ScriptWorkingSetPage extends WizardPage
implements IWorkingSetPage {
@@ -302,8 +300,8 @@ public class ScriptWorkingSetPage extends WizardPage
setPageComplete(false);
fFirstCheck = false;
return;
- } else
- errorMessage = WorkingSetMessages.ScriptWorkingSetPage_warning_nameMustNotBeEmpty;
+ }
+ errorMessage = WorkingSetMessages.ScriptWorkingSetPage_warning_nameMustNotBeEmpty;
}
fFirstCheck = false;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/WorkingSetFilter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/WorkingSetFilter.java
index 1ba45dd60..23dd22033 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/WorkingSetFilter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/WorkingSetFilter.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,8 +27,8 @@ import org.eclipse.ui.IWorkingSet;
*/
public class WorkingSetFilter extends ViewerFilter {
- private IWorkingSet fWorkingSet= null;
- private IAdaptable[] fCachedWorkingSet= null;
+ private IWorkingSet fWorkingSet = null;
+ private IAdaptable[] fCachedWorkingSet = null;
/**
* Returns the working set which is used by this filter.
@@ -42,29 +42,31 @@ public class WorkingSetFilter extends ViewerFilter {
/**
* Sets this filter's working set.
*
- * @param workingSet the working set
+ * @param workingSet
+ * the working set
*/
public void setWorkingSet(IWorkingSet workingSet) {
- fWorkingSet= workingSet;
+ fWorkingSet = workingSet;
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (fWorkingSet == null || (fWorkingSet.isAggregateWorkingSet() && fWorkingSet.getElements().length == 0))
+ if (fWorkingSet == null || (fWorkingSet.isAggregateWorkingSet()
+ && fWorkingSet.getElements().length == 0))
return true;
if (element instanceof IModelElement)
- return isEnclosing((IModelElement)element);
+ return isEnclosing((IModelElement) element);
if (element instanceof IResource)
- return isEnclosing(((IResource)element).getFullPath());
+ return isEnclosing(((IResource) element).getFullPath());
if (element instanceof BuildPathContainer) {
- return isEnclosing((BuildPathContainer)element);
+ return isEnclosing((BuildPathContainer) element);
}
if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable)element;
+ IAdaptable adaptable = (IAdaptable) element;
IModelElement je = adaptable.getAdapter(IModelElement.class);
if (je != null)
return isEnclosing(je);
@@ -79,21 +81,21 @@ public class WorkingSetFilter extends ViewerFilter {
private boolean isEnclosing(BuildPathContainer container) {
// check whether the containing ScriptFolder root is enclosed
- Object[] roots= container.getProjectFragments();
+ Object[] roots = container.getProjectFragments();
if (roots.length > 0)
- return isEnclosing((IProjectFragment)roots[0]);
+ return isEnclosing((IProjectFragment) roots[0]);
return false;
}
@Override
public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
- Object[] result= null;
+ Object[] result = null;
if (fWorkingSet != null)
- fCachedWorkingSet= fWorkingSet.getElements();
+ fCachedWorkingSet = fWorkingSet.getElements();
try {
- result= super.filter(viewer, parent, elements);
+ result = super.filter(viewer, parent, elements);
} finally {
- fCachedWorkingSet= null;
+ fCachedWorkingSet = null;
}
return result;
}
@@ -102,12 +104,12 @@ public class WorkingSetFilter extends ViewerFilter {
if (elementPath == null)
return false;
- IAdaptable[] cachedWorkingSet= fCachedWorkingSet;
+ IAdaptable[] cachedWorkingSet = fCachedWorkingSet;
if (cachedWorkingSet == null)
- cachedWorkingSet= fWorkingSet.getElements();
+ cachedWorkingSet = fWorkingSet.getElements();
- int length= cachedWorkingSet.length;
- for (int i= 0; i < length; i++) {
+ int length = cachedWorkingSet.length;
+ for (int i = 0; i < length; i++) {
if (isEnclosing(cachedWorkingSet[i], elementPath))
return true;
}
@@ -117,43 +119,47 @@ public class WorkingSetFilter extends ViewerFilter {
public boolean isEnclosing(IModelElement element) {
Assert.isNotNull(element);
- IAdaptable[] cachedWorkingSet= fCachedWorkingSet;
+ IAdaptable[] cachedWorkingSet = fCachedWorkingSet;
if (cachedWorkingSet == null)
- cachedWorkingSet= fWorkingSet.getElements();
+ cachedWorkingSet = fWorkingSet.getElements();
- boolean isElementPathComputed= false;
- IPath elementPath= null; // will be lazy computed if needed
+ boolean isElementPathComputed = false;
+ IPath elementPath = null; // will be lazy computed if needed
- int length= cachedWorkingSet.length;
- for (int i= 0; i < length; i++) {
+ int length = cachedWorkingSet.length;
+ for (int i = 0; i < length; i++) {
IModelElement scopeElement = cachedWorkingSet[i]
.getAdapter(IModelElement.class);
if (scopeElement != null) {
// compare Script elements
- IModelElement searchedElement= element;
+ IModelElement searchedElement = element;
while (searchedElement != null) {
- if (searchedElement.equals(scopeElement))
+ if (searchedElement.equals(scopeElement)) {
return true;
- else {
- if (scopeElement.getElementType() == IModelElement.SCRIPT_PROJECT && searchedElement.getElementType() == IModelElement.PROJECT_FRAGMENT) {
- IProjectFragment pkgRoot= (IProjectFragment)searchedElement;
- if (pkgRoot.isExternal() && pkgRoot.isArchive()) {
- if (((IScriptProject)scopeElement).isOnBuildpath(searchedElement))
- return true;
- }
- }
- searchedElement= searchedElement.getParent();
- if (searchedElement != null && searchedElement.getElementType() == IModelElement.SOURCE_MODULE) {
- ISourceModule unit= (ISourceModule)searchedElement;
- unit= unit.getPrimary();
+ }
+ if (scopeElement
+ .getElementType() == IModelElement.SCRIPT_PROJECT
+ && searchedElement
+ .getElementType() == IModelElement.PROJECT_FRAGMENT) {
+ IProjectFragment pkgRoot = (IProjectFragment) searchedElement;
+ if (pkgRoot.isExternal() && pkgRoot.isArchive()) {
+ if (((IScriptProject) scopeElement)
+ .isOnBuildpath(searchedElement))
+ return true;
}
}
+ searchedElement = searchedElement.getParent();
+ if (searchedElement != null && searchedElement
+ .getElementType() == IModelElement.SOURCE_MODULE) {
+ ISourceModule unit = (ISourceModule) searchedElement;
+ unit = unit.getPrimary();
+ }
}
while (scopeElement != null) {
- if (element.equals(scopeElement))
+ if (element.equals(scopeElement)) {
return true;
- else
- scopeElement= scopeElement.getParent();
+ }
+ scopeElement = scopeElement.getParent();
}
} else {
// compare resource paths
@@ -161,7 +167,7 @@ public class WorkingSetFilter extends ViewerFilter {
IResource elementResource = element
.getAdapter(IResource.class);
if (elementResource != null)
- elementPath= elementResource.getFullPath();
+ elementPath = elementResource.getFullPath();
}
if (isEnclosing(cachedWorkingSet[i], elementPath))
return true;
@@ -174,21 +180,21 @@ public class WorkingSetFilter extends ViewerFilter {
if (path == null)
return false;
- IPath elementPath= null;
+ IPath elementPath = null;
IResource elementResource = element.getAdapter(IResource.class);
if (elementResource != null)
- elementPath= elementResource.getFullPath();
+ elementPath = elementResource.getFullPath();
if (elementPath == null) {
IModelElement ScriptElement = element
.getAdapter(IModelElement.class);
if (ScriptElement != null)
- elementPath= ScriptElement.getPath();
+ elementPath = ScriptElement.getPath();
}
if (elementPath == null && element instanceof IStorage)
- elementPath= ((IStorage)element).getFullPath();
+ elementPath = ((IStorage) element).getFullPath();
if (elementPath == null)
return false;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ColorPreferenceConverter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ColorPreferenceConverter.java
index d1edf890f..1b634de3e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ColorPreferenceConverter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ColorPreferenceConverter.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
+ * Copyright (c) 2009, 2018 xored software, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -23,7 +23,7 @@ public class ColorPreferenceConverter {
/**
* Converts preference value to {@link RGB}
- *
+ *
* @param value
* @return converted value or <code>null</code>
*/
@@ -35,14 +35,13 @@ public class ColorPreferenceConverter {
if (s.length() == 0) {
// treat empty string as black color
return new RGB(0, 0, 0);
- } else {
- try {
- return StringConverter.asRGB(s);
- } catch (DataFormatException e) {
- DLTKUIPlugin.warn(NLS.bind(
- "Error parsing {0} as color value", s), e); //$NON-NLS-1$
- // fall through
- }
+ }
+ try {
+ return StringConverter.asRGB(s);
+ } catch (DataFormatException e) {
+ DLTKUIPlugin.warn(
+ NLS.bind("Error parsing {0} as color value", s), e); //$NON-NLS-1$
+ // fall through
}
}
return null;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ModelElementSorter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ModelElementSorter.java
index c3dad7a47..4657b71b4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ModelElementSorter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ModelElementSorter.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,8 @@ import com.ibm.icu.text.Collator;
* name. Package fragment roots are sorted as ordered on the buildpath.
*
*/
-public class ModelElementSorter extends ViewerSorter implements
- IModelCompareCategories {
+public class ModelElementSorter extends ViewerSorter
+ implements IModelCompareCategories {
private MembersOrderPreferenceCache fMemberOrderCache;
private Collator fNewCollator; // collator from ICU
@@ -90,25 +90,29 @@ public class ModelElementSorter extends ViewerSorter implements
case IModelElement.METHOD: {
IMethod method = (IMethod) je;
if (method.isConstructor()) {
- return getMemberCategory(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX);
+ return getMemberCategory(
+ MembersOrderPreferenceCache.CONSTRUCTORS_INDEX);
}
- return getMemberCategory(MembersOrderPreferenceCache.METHOD_INDEX);
+ return getMemberCategory(
+ MembersOrderPreferenceCache.METHOD_INDEX);
}
case IModelElement.FIELD: {
- return getMemberCategory(MembersOrderPreferenceCache.FIELDS_INDEX);
+ return getMemberCategory(
+ MembersOrderPreferenceCache.FIELDS_INDEX);
}
- // case IModelElement.INITIALIZER :
- // {
- // int flags= ((IInitializer) je).getFlags();
- // if (Flags.isStatic(flags))
- // return
- // getMemberCategory(MembersOrderPreferenceCache.STATIC_INIT_INDEX);
- // else
- // return
- // getMemberCategory(MembersOrderPreferenceCache.INIT_INDEX);
- // }
+ // case IModelElement.INITIALIZER :
+ // {
+ // int flags= ((IInitializer) je).getFlags();
+ // if (Flags.isStatic(flags))
+ // return
+ // getMemberCategory(MembersOrderPreferenceCache.STATIC_INIT_INDEX);
+ // else
+ // return
+ // getMemberCategory(MembersOrderPreferenceCache.INIT_INDEX);
+ // }
case IModelElement.TYPE:
- return getMemberCategory(MembersOrderPreferenceCache.TYPE_INDEX);
+ return getMemberCategory(
+ MembersOrderPreferenceCache.TYPE_INDEX);
case IModelElement.PACKAGE_DECLARATION:
return PACKAGE_DECL;
case IModelElement.IMPORT_CONTAINER:
@@ -182,9 +186,8 @@ public class ModelElementSorter extends ViewerSorter implements
if (root1 == null) {
if (root2 == null) {
return 0;
- } else {
- return 1;
}
+ return 1;
} else if (root2 == null) {
return -1;
}
@@ -237,9 +240,8 @@ public class ModelElementSorter extends ViewerSorter implements
} catch (ModelException e) {
return 0;
}
- } else {
- return 1;
}
+ return 1;
} else if (name2.length() == 0) {
return -1;
}
@@ -342,9 +344,12 @@ public class ModelElementSorter extends ViewerSorter implements
if ((cat1 == PROJECTFRAGMENT && cat2 == PROJECTFRAGMENT)
|| (cat1 == CONTAINER && cat2 == CONTAINER)
|| (cat1 == SCRIPTFOLDER
- && ((IScriptFolder) e1).getParent().getResource() instanceof IProject && cat2 == PROJECTFRAGMENT)
- || (cat1 == PROJECTFRAGMENT && cat2 == SCRIPTFOLDER && ((IScriptFolder) e2)
- .getParent().getResource() instanceof IProject)) {
+ && ((IScriptFolder) e1).getParent()
+ .getResource() instanceof IProject
+ && cat2 == PROJECTFRAGMENT)
+ || (cat1 == PROJECTFRAGMENT && cat2 == SCRIPTFOLDER
+ && ((IScriptFolder) e2).getParent()
+ .getResource() instanceof IProject)) {
IScriptProject p1 = getScriptProject(e1);
return p1 != null && p1.equals(getScriptProject(e2));
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ScriptElementImageProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ScriptElementImageProvider.java
index 8b604dd85..a82a08b92 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ScriptElementImageProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/ScriptElementImageProvider.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
@@ -88,7 +88,7 @@ public class ScriptElementImageProvider {
* for <code>ISourceReference</code>s.
*
* @param flags
- * Flags as defined by the ScriptImageLabelProvider
+ * Flags as defined by the ScriptImageLabelProvider
*/
public Image getImageLabel(Object element, int flags) {
return getImageLabel(computeDescriptor(element, flags));
@@ -197,9 +197,8 @@ public class ScriptElementImageProvider {
if (descr != null) {
return new ScriptElementImageDescriptor(descr, adornmentFlags,
size);
- } else {
- return null;
}
+ return null;
}
/**
@@ -255,12 +254,10 @@ public class ScriptElementImageProvider {
if (root.isExternal()) {
if (root.isArchive()) {
return DLTKPluginImages.DESC_OBJS_JAR_WSRC;
- } else {
- return DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT;
}
- } else {
return DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT;
}
+ return DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT;
}
case IModelElement.SCRIPT_FOLDER:
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/FindAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/FindAction.java
index b8da5c4e8..348951029 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/FindAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/FindAction.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
@@ -48,25 +48,24 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
-
/**
* Abstract class for Script search actions.
* <p>
* Note: This class is for internal use only. Clients should not use this class.
* </p>
*
- *
+ *
*/
public abstract class FindAction extends SelectionDispatchAction {
// A dummy which can't be selected in the UI
- private static final IModelElement RETURN_WITHOUT_BEEP= DLTKCore.create(DLTKUIPlugin.getWorkspace().getRoot());
+ private static final IModelElement RETURN_WITHOUT_BEEP = DLTKCore
+ .create(DLTKUIPlugin.getWorkspace().getRoot());
private Class[] fValidTypes;
private final IDLTKLanguageToolkit toolkit;
private AbstractDecoratedTextEditor fEditor;
-
FindAction(IDLTKLanguageToolkit toolkit, IWorkbenchSite site) {
super(site);
this.toolkit = toolkit;
@@ -93,32 +92,36 @@ public abstract class FindAction extends SelectionDispatchAction {
}
/**
- * Called once by the constructors to initialize label, tooltip, image and help support of the action.
- * To be overridden by implementors of this action.
+ * Called once by the constructors to initialize label, tooltip, image and
+ * help support of the action. To be overridden by implementors of this
+ * action.
*/
abstract void init();
/**
- * Called once by the constructors to get the list of the valid input types of the action.
- * To be overridden by implementors of this action.
+ * Called once by the constructors to get the list of the valid input types
+ * of the action. To be overridden by implementors of this action.
+ *
* @return the valid input types of the action
*/
abstract Class[] getValidTypes();
private boolean canOperateOn(IStructuredSelection sel) {
- return sel != null && !sel.isEmpty() && canOperateOn(getModelElement(sel, true));
+ return sel != null && !sel.isEmpty()
+ && canOperateOn(getModelElement(sel, true));
}
boolean canOperateOn(IModelElement element) {
- if (element == null || fValidTypes == null || fValidTypes.length == 0 || !ActionUtil.isOnBuildPath(element))
+ if (element == null || fValidTypes == null || fValidTypes.length == 0
+ || !ActionUtil.isOnBuildPath(element))
return false;
- for (int i= 0; i < fValidTypes.length; i++) {
+ for (int i = 0; i < fValidTypes.length; i++) {
if (fValidTypes[i].isInstance(element)) {
- if (element.getElementType() == IModelElement.SCRIPT_FOLDER)
- return hasChildren((IScriptFolder)element);
- else
- return true;
+ if (element.getElementType() == IModelElement.SCRIPT_FOLDER) {
+ return hasChildren((IScriptFolder) element);
+ }
+ return true;
}
}
return false;
@@ -134,22 +137,23 @@ public abstract class FindAction extends SelectionDispatchAction {
private IModelElement getTypeIfPossible(IModelElement o, boolean silent) {
switch (o.getElementType()) {
- case IModelElement.SOURCE_MODULE:
- if (silent)
- return o;
- else
- return findType((ISourceModule)o, silent);
- default:
+ case IModelElement.SOURCE_MODULE:
+ if (silent) {
return o;
+ }
+ return findType((ISourceModule) o, silent);
+ default:
+ return o;
}
}
- IModelElement getModelElement(IStructuredSelection selection, boolean silent) {
+ IModelElement getModelElement(IStructuredSelection selection,
+ boolean silent) {
if (selection.size() == 1) {
- Object firstElement= selection.getFirstElement();
- IModelElement elem= null;
+ Object firstElement = selection.getFirstElement();
+ IModelElement elem = null;
if (firstElement instanceof IModelElement)
- elem= (IModelElement) firstElement;
+ elem = (IModelElement) firstElement;
else if (firstElement instanceof IAdaptable)
elem = ((IAdaptable) firstElement)
.getAdapter(IModelElement.class);
@@ -162,7 +166,9 @@ public abstract class FindAction extends SelectionDispatchAction {
}
private void showOperationUnavailableDialog() {
- MessageDialog.openInformation(getShell(), SearchMessages.DLTKElementAction_operationUnavailable_title, getOperationUnavailableMessage());
+ MessageDialog.openInformation(getShell(),
+ SearchMessages.DLTKElementAction_operationUnavailable_title,
+ getOperationUnavailableMessage());
}
String getOperationUnavailableMessage() {
@@ -175,16 +181,17 @@ public abstract class FindAction extends SelectionDispatchAction {
}
private IModelElement findType(ISourceModule cu, boolean silent) {
- IType[] types= null;
+ IType[] types = null;
try {
- types= cu.getTypes();
+ types = cu.getTypes();
} catch (ModelException ex) {
if (ScriptModelUtil.isExceptionToBeLogged(ex))
- ExceptionHandler.log(ex, SearchMessages.DLTKElementAction_error_open_message);
- if (silent)
+ ExceptionHandler.log(ex,
+ SearchMessages.DLTKElementAction_error_open_message);
+ if (silent) {
return RETURN_WITHOUT_BEEP;
- else
- return null;
+ }
+ return null;
}
if (types.length == 1 || (silent && types.length > 0))
return types[0];
@@ -192,29 +199,29 @@ public abstract class FindAction extends SelectionDispatchAction {
return RETURN_WITHOUT_BEEP;
if (types.length == 0)
return null;
- String title= SearchMessages.DLTKElementAction_typeSelectionDialog_title;
+ String title = SearchMessages.DLTKElementAction_typeSelectionDialog_title;
String message = SearchMessages.DLTKElementAction_typeSelectionDialog_message;
- int flags= (ModelElementLabelProvider.SHOW_DEFAULT);
+ int flags = (ModelElementLabelProvider.SHOW_DEFAULT);
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new ModelElementLabelProvider(flags));
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(
+ getShell(), new ModelElementLabelProvider(flags));
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setElements(types);
- if (dialog.open() == Window.OK)
- return (IType)dialog.getFirstResult();
- else
- return RETURN_WITHOUT_BEEP;
+ if (dialog.open() == Window.OK) {
+ return (IType) dialog.getFirstResult();
+ }
+ return RETURN_WITHOUT_BEEP;
}
@Override
public void run(IStructuredSelection selection) {
- IModelElement element= getModelElement(selection, false);
+ IModelElement element = getModelElement(selection, false);
if (element == null || !element.exists()) {
showOperationUnavailableDialog();
return;
- }
- else if (element == RETURN_WITHOUT_BEEP)
+ } else if (element == RETURN_WITHOUT_BEEP)
return;
run(element);
@@ -225,22 +232,23 @@ public abstract class FindAction extends SelectionDispatchAction {
if (!ActionUtil.isProcessable(getShell(), fEditor))
return;
try {
- String title= SearchMessages.SearchElementSelectionDialog_title;
- String message= SearchMessages.SearchElementSelectionDialog_message;
+ String title = SearchMessages.SearchElementSelectionDialog_title;
+ String message = SearchMessages.SearchElementSelectionDialog_message;
- IModelElement[] elements= SelectionConverter.codeResolveForked(fEditor, true);
+ IModelElement[] elements = SelectionConverter
+ .codeResolveForked(fEditor, true);
if (elements.length > 0 && canOperateOn(elements[0])) {
- IModelElement element= elements[0];
+ IModelElement element = elements[0];
if (elements.length > 1)
- element= OpenActionUtil.selectModelElement(elements, getShell(), title, message);
+ element = OpenActionUtil.selectModelElement(elements,
+ getShell(), title, message);
if (element != null)
run(element);
- }
- else
+ } else
showOperationUnavailableDialog();
} catch (InvocationTargetException ex) {
- String title= SearchMessages.Search_Error_search_title;
- String message= SearchMessages.Search_Error_codeResolve;
+ String title = SearchMessages.Search_Error_search_title;
+ String message = SearchMessages.Search_Error_codeResolve;
ExceptionHandler.handle(ex, getShell(), title, message);
} catch (InterruptedException e) {
// ignore
@@ -258,7 +266,9 @@ public abstract class FindAction extends SelectionDispatchAction {
/**
* Executes this action for the givenscriptelement.
- * @param element Thescriptelement to be found.
+ *
+ * @param element
+ * Thescriptelement to be found.
*/
public void run(IModelElement element) {
@@ -269,31 +279,40 @@ public abstract class FindAction extends SelectionDispatchAction {
try {
performNewSearch(element);
} catch (ModelException ex) {
- ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message);
+ ExceptionHandler.handle(ex, getShell(),
+ SearchMessages.Search_Error_search_notsuccessful_title,
+ SearchMessages.Search_Error_search_notsuccessful_message);
}
}
private void performNewSearch(IModelElement element) throws ModelException {
- DLTKSearchQuery query= new DLTKSearchQuery(createQuery(element));
+ DLTKSearchQuery query = new DLTKSearchQuery(createQuery(element));
if (query.canRunInBackground()) {
/*
- * This indirection 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 indirection 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).
*/
SearchUtil.runQueryInBackground(query);
} else {
- IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
+ IProgressService progressService = PlatformUI.getWorkbench()
+ .getProgressService();
/*
- * This indirection 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 it would be ISearchQuery).
+ * This indirection 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 it would be ISearchQuery).
*/
- IStatus status= SearchUtil.runQueryInForeground(progressService, query);
- if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
- ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status);
+ IStatus status = SearchUtil.runQueryInForeground(progressService,
+ query);
+ if (status
+ .matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
+ ErrorDialog.openError(getShell(),
+ SearchMessages.Search_Error_search_title,
+ SearchMessages.Search_Error_search_message, status);
}
}
}
@@ -302,11 +321,14 @@ public abstract class FindAction extends SelectionDispatchAction {
return toolkit;
}
- QuerySpecification createQuery(IModelElement element) throws ModelException {
- DLTKSearchScopeFactory factory= DLTKSearchScopeFactory.getInstance();
- IDLTKSearchScope scope= factory.createWorkspaceScope(true, getLanguageToolkit());
- String description= factory.getWorkspaceScopeDescription(true);
- return new ElementQuerySpecification(element, getLimitTo(), scope, description);
+ QuerySpecification createQuery(IModelElement element)
+ throws ModelException {
+ DLTKSearchScopeFactory factory = DLTKSearchScopeFactory.getInstance();
+ IDLTKSearchScope scope = factory.createWorkspaceScope(true,
+ getLanguageToolkit());
+ String description = factory.getWorkspaceScopeDescription(true);
+ return new ElementQuerySpecification(element, getLimitTo(), scope,
+ description);
}
abstract int getLimitTo();
@@ -315,11 +337,11 @@ public abstract class FindAction extends SelectionDispatchAction {
if (element == null)
return null;
- IType type= null;
+ IType type = null;
if (element.getElementType() == IModelElement.TYPE)
- type= (IType)element;
+ type = (IType) element;
else if (element instanceof IMember)
- type= ((IMember)element).getDeclaringType();
+ type = ((IMember) element).getDeclaringType();
// else if (element instanceof ILocalVariable) {
// type= (IType)element.getAncestor(IModelElement.TYPE);
// }
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/IndentAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/IndentAction.java
index 60da6fd4c..20924e9ed 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/IndentAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/IndentAction.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 xored software, Inc.
+ * Copyright (c) 2010, 2018 xored software, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
@@ -52,7 +52,7 @@ import org.eclipse.ui.texteditor.TextEditorAction;
/**
* Indents a line or range of lines in a script document to its correct
* position.
- *
+ *
* @since 2.0
*/
public class IndentAction extends TextEditorAction {
@@ -65,15 +65,16 @@ public class IndentAction extends TextEditorAction {
/**
* Creates a new instance.
- *
+ *
* @param bundle
- * the resource bundle
+ * the resource bundle
* @param prefix
- * the prefix to use for keys in <code>bundle</code>
+ * the prefix to use for keys in <code>bundle</code>
* @param editor
- * the text editor
+ * the text editor
* @param isTabAction
- * whether the action should insert tabs if over the indentation
+ * whether the action should insert tabs if over the
+ * indentation
*/
public IndentAction(ResourceBundle bundle, String prefix,
ITextEditor editor, boolean isTabAction) {
@@ -149,13 +150,13 @@ public class IndentAction extends TextEditorAction {
project);
if (factory != null) {
Map<String, String> preferences = factory
- .retrievePreferences(new PreferencesLookupDelegate(
- project));
+ .retrievePreferences(
+ new PreferencesLookupDelegate(project));
preferences = factory.changeToIndentingOnly(preferences);
final String lineDelimiter = TextUtilities
.getDefaultLineDelimiter(document);
- final IScriptFormatter formatter = factory.createFormatter(
- lineDelimiter, preferences);
+ final IScriptFormatter formatter = factory
+ .createFormatter(lineDelimiter, preferences);
if (project != null
&& formatter instanceof IScriptFormatterExtension) {
((IScriptFormatterExtension) formatter)
@@ -200,8 +201,8 @@ public class IndentAction extends TextEditorAction {
+ lastLineRegion.getLength();
int level = formatter.detectIndentationLevel(document, startOffset);
final String source = document.get();
- final TextEdit edit = formatter.format(source, startOffset, lastOffset
- - startOffset, level);
+ final TextEdit edit = formatter.format(source, startOffset,
+ lastOffset - startOffset, level);
if (edit == null) {
return false;
}
@@ -249,7 +250,7 @@ public class IndentAction extends TextEditorAction {
/**
* Returns the editor's selection provider.
- *
+ *
* @return the editor's selection provider or <code>null</code>
*/
private ISelectionProvider getSelectionProvider() {
@@ -278,7 +279,7 @@ public class IndentAction extends TextEditorAction {
* Returns if the current selection is valid, i.e. whether it is empty and
* the caret in the whitespace at the start of a line, or covers multiple
* lines.
- *
+ *
* @return <code>true</code> if the selection is valid for an indent
* operation
*/
@@ -297,12 +298,12 @@ public class IndentAction extends TextEditorAction {
// either the selection has to be empty and the caret in the WS at
// the line start
// or the selection has to extend over multiple lines
- if (length == 0)
+ if (length == 0) {
return document.get(lineOffset, offset - lineOffset).trim()
.length() == 0;
- else
- // return lineOffset + firstLine.getLength() < offset + length;
- return false; // only enable for empty selections for now
+ }
+ // return lineOffset + firstLine.getLength() < offset + length;
+ return false; // only enable for empty selections for now
} catch (BadLocationException e) {
}
return false;
@@ -310,24 +311,25 @@ public class IndentAction extends TextEditorAction {
/**
* Returns the smart preference state.
- *
+ *
* @return <code>true</code> if smart mode is on, <code>false</code>
* otherwise
*/
private boolean isSmartMode() {
ITextEditor editor = getTextEditor();
if (editor instanceof ITextEditorExtension3)
- return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
+ return ((ITextEditorExtension3) editor)
+ .getInsertMode() == ITextEditorExtension3.SMART_INSERT;
return false;
}
/**
* Selects the given range on the editor.
- *
+ *
* @param newOffset
- * the selection offset
+ * the selection offset
* @param newLength
- * the selection range
+ * the selection range
*/
private void selectAndReveal(int newOffset, int newLength) {
Assert.isTrue(newOffset >= 0);
@@ -345,7 +347,7 @@ public class IndentAction extends TextEditorAction {
/**
* Returns a tab equivalent, either as a tab character or as spaces,
* depending on the editor and formatter preferences.
- *
+ *
* @return a string representing one tab in the editor, never
* <code>null</code>
*/
@@ -357,8 +359,8 @@ public class IndentAction extends TextEditorAction {
final IPreferenceStore prefs = ((ScriptEditor) editor)
.getScriptPreferenceStore();
String tab;
- if (CodeFormatterConstants.SPACE.equals(prefs
- .getString(CodeFormatterConstants.FORMATTER_TAB_CHAR))) {
+ if (CodeFormatterConstants.SPACE.equals(
+ prefs.getString(CodeFormatterConstants.FORMATTER_TAB_CHAR))) {
final int tabSize = prefs
.getInt(CodeFormatterConstants.FORMATTER_TAB_SIZE);
int wsLen = whiteSpaceLength(indent, tabSize);
@@ -371,24 +373,23 @@ public class IndentAction extends TextEditorAction {
/**
* Returns the size in characters of a string. All characters count one,
* tabs count the editor's preference for the tab display
- *
+ *
* @param indent
- * the string to be measured.
+ * the string to be measured.
* @param project
- * the project to retrieve the indentation settings from,
- * <b>null</b> for workspace settings
+ * the project to retrieve the indentation settings from,
+ * <b>null</b> for workspace settings
* @return the size in characters of a string
*/
private static int whiteSpaceLength(String indent, int tabSize) {
- if (indent == null)
+ if (indent == null) {
return 0;
- else {
- int size = 0;
- int l = indent.length();
- for (int i = 0; i < l; i++)
- size += indent.charAt(i) == '\t' ? tabSize : 1;
- return size;
}
+ int size = 0;
+ int l = indent.length();
+ for (int i = 0; i < l; i++)
+ size += indent.charAt(i) == '\t' ? tabSize : 1;
+ return size;
}
private String getPrevIndent(IDocument document, int n)
@@ -406,7 +407,7 @@ public class IndentAction extends TextEditorAction {
/**
* Returns the document currently displayed in the editor, or
* <code>null</code> if none can be obtained.
- *
+ *
* @return the current document or <code>null</code>
*/
private IDocument getDocument() {
@@ -423,7 +424,7 @@ public class IndentAction extends TextEditorAction {
/**
* Returns the selection on the editor or an invalid selection if none can
* be obtained. Returns never <code>null</code>.
- *
+ *
* @return the current selection, never <code>null</code>
*/
private ITextSelection getSelection() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/SelectionDispatchAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/SelectionDispatchAction.java
index d019da741..4abe4bbec 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/SelectionDispatchAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/actions/SelectionDispatchAction.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
@@ -22,23 +22,24 @@ import org.eclipse.ui.IWorkbenchSite;
/**
* Action that dispatches the <code>IAction#run()</code> and the
- * <code>ISelectionChangedListener#selectionChanged</code>
- * according to the type of the selection.
+ * <code>ISelectionChangedListener#selectionChanged</code> according to the type
+ * of the selection.
*
* <ul>
- * <li>if selection is of type <code>ITextSelection</code> then
- * <code>run(ITextSelection)</code> and <code>selectionChanged(ITextSelection)</code>
- * is called.</li>
- * <li>if selection is of type <code>IStructuredSelection</code> then
- * <code>run(IStructuredSelection)</code> and <code>
+ * <li>if selection is of type <code>ITextSelection</code> then
+ * <code>run(ITextSelection)</code> and
+ * <code>selectionChanged(ITextSelection)</code> is called.</li>
+ * <li>if selection is of type <code>IStructuredSelection</code> then
+ * <code>run(IStructuredSelection)</code> and <code>
* selectionChanged(IStructuredSelection)</code> is called.</li>
- * <li>default is to call <code>run(ISelection)</code> and <code>
+ * <li>default is to call <code>run(ISelection)</code> and <code>
* selectionChanged(ISelection)</code>.</li>
* </ul>
*
*
*/
-public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
+public abstract class SelectionDispatchAction extends Action
+ implements ISelectionChangedListener {
private IWorkbenchSite fSite;
private ISelectionProvider fSpecialSelectionProvider;
@@ -49,11 +50,12 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* Configure the action later using the set methods.
* </p>
*
- * @param site the site this action is working on
+ * @param site
+ * the site this action is working on
*/
protected SelectionDispatchAction(IWorkbenchSite site) {
Assert.isNotNull(site);
- fSite= site;
+ fSite = site;
}
/**
@@ -63,18 +65,23 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* Configure the action later using the set methods.
* </p>
*
- * @param site the site this action is working on
- * @param provider a special selection provider which is used
- * instead of the site's selection provider or <code>null</code> to use the site's
- * selection provider. Clients can for example use a {@link ConvertingSelectionProvider}
- * to first convert a selection before passing it to the action.
+ * @param site
+ * the site this action is working on
+ * @param provider
+ * a special selection provider which is used instead of
+ * the site's selection provider or <code>null</code> to
+ * use the site's selection provider. Clients can for
+ * example use a {@link ConvertingSelectionProvider} to
+ * first convert a selection before passing it to the
+ * action.
*
*
- * @deprecated Use {@link #setSpecialSelectionProvider(ISelectionProvider)} instead. This constructor will be
- * removed after 3.2 M5.
+ * @deprecated Use {@link #setSpecialSelectionProvider(ISelectionProvider)}
+ * instead. This constructor will be removed after 3.2 M5.
*/
@Deprecated
- protected SelectionDispatchAction(IWorkbenchSite site, ISelectionProvider provider) {
+ protected SelectionDispatchAction(IWorkbenchSite site,
+ ISelectionProvider provider) {
this(site);
setSpecialSelectionProvider(provider);
}
@@ -94,11 +101,11 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
* @return the site's selection
*/
public ISelection getSelection() {
- ISelectionProvider selectionProvider= getSelectionProvider();
- if (selectionProvider != null)
+ ISelectionProvider selectionProvider = getSelectionProvider();
+ if (selectionProvider != null) {
return selectionProvider.getSelection();
- else
- return null;
+ }
+ return null;
}
/**
@@ -111,8 +118,9 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
}
/**
- * Returns the selection provider managed by the site owning this action or the selection
- * provider explicitly set in {@link #setSpecialSelectionProvider(ISelectionProvider)}.
+ * Returns the selection provider managed by the site owning this action or
+ * the selection provider explicitly set in
+ * {@link #setSpecialSelectionProvider(ISelectionProvider)}.
*
* @return the site's selection provider
*/
@@ -124,105 +132,124 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
}
/**
- * Sets a special selection provider which will be used instead of the site's selection provider.
- * This method should be used directly after constructing the action and before the action is
- * registered as a selection listener. The invocation will not a perform a selection change notification.
+ * Sets a special selection provider which will be used instead of the
+ * site's selection provider. This method should be used directly after
+ * constructing the action and before the action is registered as a
+ * selection listener. The invocation will not a perform a selection change
+ * notification.
*
- * @param provider a special selection provider which is used
- * instead of the site's selection provider or <code>null</code> to use the site's
- * selection provider. Clients can for example use a {@link ConvertingSelectionProvider}
- * to first convert a selection before passing it to the action.
+ * @param provider
+ * a special selection provider which is used instead of
+ * the site's selection provider or <code>null</code> to
+ * use the site's selection provider. Clients can for
+ * example use a {@link ConvertingSelectionProvider} to
+ * first convert a selection before passing it to the
+ * action.
*
*
*/
public void setSpecialSelectionProvider(ISelectionProvider provider) {
- fSpecialSelectionProvider= provider;
+ fSpecialSelectionProvider = provider;
}
/**
- * Updates the action's enablement state according to the given selection. This
- * default implementation calls one of the <code>selectionChanged</code>
- * methods depending on the type of the passed selection.
+ * Updates the action's enablement state according to the given selection.
+ * This default implementation calls one of the
+ * <code>selectionChanged</code> methods depending on the type of the passed
+ * selection.
*
- * @param selection the selection this action is working on
+ * @param selection
+ * the selection this action is working on
*/
public void update(ISelection selection) {
dispatchSelectionChanged(selection);
}
/**
- * Notifies this action that the given structured selection has changed. This default
- * implementation calls <code>selectionChanged(ISelection selection)</code>.
+ * Notifies this action that the given structured selection has changed.
+ * This default implementation calls
+ * <code>selectionChanged(ISelection selection)</code>.
*
- * @param selection the new selection
- */
+ * @param selection
+ * the new selection
+ */
public void selectionChanged(IStructuredSelection selection) {
- selectionChanged((ISelection)selection);
+ selectionChanged((ISelection) selection);
}
/**
- * Executes this actions with the given structured selection. This default implementation
- * calls <code>run(ISelection selection)</code>.
+ * Executes this actions with the given structured selection. This default
+ * implementation calls <code>run(ISelection selection)</code>.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public void run(IStructuredSelection selection) {
- run((ISelection)selection);
+ run((ISelection) selection);
}
/**
- * Note: This method is for internal use only. Clients should not call this method.
+ * Note: This method is for internal use only. Clients should not call this
+ * method.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public void selectionChanged(ModelTextSelection selection) {
- selectionChanged((ITextSelection)selection);
+ selectionChanged((ITextSelection) selection);
}
/**
- * Note: This method is for internal use only. Clients should not call this method.
+ * Note: This method is for internal use only. Clients should not call this
+ * method.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public void run(ModelTextSelection selection) {
- run((ITextSelection)selection);
+ run((ITextSelection) selection);
}
/**
- * Notifies this action that the given text selection has changed. This default
- * implementation calls <code>selectionChanged(ISelection selection)</code>.
+ * Notifies this action that the given text selection has changed. This
+ * default implementation calls
+ * <code>selectionChanged(ISelection selection)</code>.
*
- * @param selection the new selection
- */
+ * @param selection
+ * the new selection
+ */
public void selectionChanged(ITextSelection selection) {
- selectionChanged((ISelection)selection);
+ selectionChanged((ISelection) selection);
}
/**
- * Executes this actions with the given text selection. This default implementation
- * calls <code>run(ISelection selection)</code>.
+ * Executes this actions with the given text selection. This default
+ * implementation calls <code>run(ISelection selection)</code>.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public void run(ITextSelection selection) {
- run((ISelection)selection);
+ run((ISelection) selection);
}
/**
- * Notifies this action that the given selection has changed. This default
+ * Notifies this action that the given selection has changed. This default
* implementation sets the action's enablement state to <code>false</code>.
*
- * @param selection the new selection
- */
+ * @param selection
+ * the new selection
+ */
public void selectionChanged(ISelection selection) {
setEnabled(false);
}
/**
- * Executes this actions with the given selection. This default implementation
- * does nothing.
+ * Executes this actions with the given selection. This default
+ * implementation does nothing.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public void run(ISelection selection) {
}
@@ -239,11 +266,11 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
private void dispatchSelectionChanged(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- selectionChanged((IStructuredSelection)selection);
+ selectionChanged((IStructuredSelection) selection);
} else if (selection instanceof ModelTextSelection) {
- selectionChanged((ModelTextSelection)selection);
+ selectionChanged((ModelTextSelection) selection);
} else if (selection instanceof ITextSelection) {
- selectionChanged((ITextSelection)selection);
+ selectionChanged((ITextSelection) selection);
} else {
selectionChanged(selection);
}
@@ -251,11 +278,11 @@ public abstract class SelectionDispatchAction extends Action implements ISelecti
private void dispatchRun(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- run((IStructuredSelection)selection);
+ run((IStructuredSelection) selection);
} else if (selection instanceof ModelTextSelection) {
- run((ModelTextSelection)selection);
- } else if (selection instanceof ITextSelection) {
- run((ITextSelection)selection);
+ run((ModelTextSelection) selection);
+ } else if (selection instanceof ITextSelection) {
+ run((ITextSelection) selection);
} else {
run(selection);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackage.java
index aed21f317..20b216562 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackage.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
@@ -136,10 +136,9 @@ public class LogicalPackage extends PlatformObject {
}
private int getHash(IScriptFolder[] fragments, int index) {
- if (index <= 0)
+ if (index <= 0) {
return fragments[0].hashCode() * 17;
- else
- return fragments[index].hashCode() * 17
- + getHash(fragments, index - 1);
+ }
+ return fragments[index].hashCode() * 17 + getHash(fragments, index - 1);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackagesProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackagesProvider.java
index 303ce2ecb..98b44dc33 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackagesProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/LogicalPackagesProvider.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
@@ -31,9 +31,10 @@ import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElementChangedListener {
+abstract class LogicalPackagesProvider
+ implements IPropertyChangeListener, IElementChangedListener {
- protected static final Object[] NO_CHILDREN= new Object[0];
+ protected static final Object[] NO_CHILDREN = new Object[0];
protected Map fMapToLogicalPackage;
protected Map fMapToPackageFragments;
@@ -41,83 +42,90 @@ abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElem
protected StructuredViewer fViewer;
protected boolean fInputIsProject;
- public LogicalPackagesProvider(StructuredViewer viewer){
- fViewer= viewer;
- fCompoundState= isInCompoundState();
- fInputIsProject= true;
- fMapToLogicalPackage= new HashMap();
- fMapToPackageFragments= new HashMap();
- DLTKUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+ public LogicalPackagesProvider(StructuredViewer viewer) {
+ fViewer = viewer;
+ fCompoundState = isInCompoundState();
+ fInputIsProject = true;
+ fMapToLogicalPackage = new HashMap();
+ fMapToPackageFragments = new HashMap();
+ DLTKUIPlugin.getDefault().getPreferenceStore()
+ .addPropertyChangeListener(this);
}
/**
- * Adds the given fragments to the internal map.
- * Existing fragments will be replaced by the new ones.
+ * Adds the given fragments to the internal map. Existing fragments will be
+ * replaced by the new ones.
*
- * @param packageFragments the package fragments to add
+ * @param packageFragments
+ * the package fragments to add
*/
protected void addFragmentsToMap(IScriptFolder[] packageFragments) {
- for (int i= 0; i < packageFragments.length; i++) {
- IScriptFolder fragment= packageFragments[i];
- String key= getKey(fragment);
+ for (int i = 0; i < packageFragments.length; i++) {
+ IScriptFolder fragment = packageFragments[i];
+ String key = getKey(fragment);
fMapToPackageFragments.put(key, fragment);
}
}
protected String getKey(IScriptFolder fragment) {
- return fragment.getElementName() + fragment.getScriptProject().getElementName();
+ return fragment.getElementName()
+ + fragment.getScriptProject().getElementName();
}
/**
- * Returns the logical package for the given package fragment
- * or <code>null</code> if it is not grouped by logical package.
+ * Returns the logical package for the given package fragment or
+ * <code>null</code> if it is not grouped by logical package.
*
- * @param fragment the package fragment
+ * @param fragment
+ * the package fragment
* @return the logical package
*/
public LogicalPackage findLogicalPackage(IScriptFolder fragment) {
Assert.isNotNull(fragment);
- if (isInCompoundState())
- return (LogicalPackage)fMapToLogicalPackage.get(getKey(fragment));
- else
- return null;
+ if (isInCompoundState()) {
+ return (LogicalPackage) fMapToLogicalPackage.get(getKey(fragment));
+ }
+ return null;
}
/**
- * Combines packages with same names into a logical package which will
- * be added to the resulting array. If a package is not yet in this content
+ * Combines packages with same names into a logical package which will be
+ * added to the resulting array. If a package is not yet in this content
* provider then the package fragment is added to the resulting array.
*
- * @param packageFragments the package fragments to combine
+ * @param packageFragments
+ * the package fragments to combine
* @return an array with combined (logical) packages and package fragments
*/
- protected Object[] combineSamePackagesIntoLogialPackages(IScriptFolder[] packageFragments) {
+ protected Object[] combineSamePackagesIntoLogialPackages(
+ IScriptFolder[] packageFragments) {
if (!fCompoundState)
return packageFragments;
- List newChildren= new ArrayList();
+ List newChildren = new ArrayList();
- for (int i= 0; i < packageFragments.length; i++) {
- IScriptFolder fragment= packageFragments[i];
+ for (int i = 0; i < packageFragments.length; i++) {
+ IScriptFolder fragment = packageFragments[i];
if (fragment == null)
continue;
- LogicalPackage lp= findLogicalPackage(fragment);
+ LogicalPackage lp = findLogicalPackage(fragment);
if (lp != null) {
if (lp.belongs(fragment)) {
lp.add(fragment);
}
- if(!newChildren.contains(lp))
+ if (!newChildren.contains(lp))
newChildren.add(lp);
} else {
- String key= getKey(fragment);
- IScriptFolder frag= (IScriptFolder)fMapToPackageFragments.get(key);
+ String key = getKey(fragment);
+ IScriptFolder frag = (IScriptFolder) fMapToPackageFragments
+ .get(key);
if (frag != null && !fragment.equals(frag)) {
- lp= new LogicalPackage(frag);
+ lp = new LogicalPackage(frag);
lp.add(fragment);
newChildren.remove(frag);
newChildren.add(lp);
@@ -134,19 +142,19 @@ abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElem
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (fCompoundState == isInCompoundState())
+ if (fCompoundState == isInCompoundState()) {
return;
- else
- fCompoundState= isInCompoundState();
+ }
+ fCompoundState = isInCompoundState();
if (!isInCompoundState()) {
fMapToLogicalPackage.clear();
fMapToPackageFragments.clear();
}
- if(fViewer instanceof TreeViewer){
- TreeViewer viewer= (TreeViewer) fViewer;
- Object[] expandedObjects= viewer.getExpandedElements();
+ if (fViewer instanceof TreeViewer) {
+ TreeViewer viewer = (TreeViewer) fViewer;
+ Object[] expandedObjects = viewer.getExpandedElements();
viewer.refresh();
viewer.setExpandedElements(expandedObjects);
} else
@@ -154,15 +162,17 @@ abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElem
}
protected boolean isInCompoundState() {
- // XXX: for now we don't offer a preference might become a view menu entry
- // return AppearancePreferencePage.logicalPackagesInPackagesView();
+ // XXX: for now we don't offer a preference might become a view menu
+ // entry
+ // return AppearancePreferencePage.logicalPackagesInPackagesView();
return true;
}
- public void dispose(){
- DLTKUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- fMapToLogicalPackage= null;
- fMapToPackageFragments= null;
+ public void dispose() {
+ DLTKUIPlugin.getDefault().getPreferenceStore()
+ .removePropertyChangeListener(this);
+ fMapToLogicalPackage = null;
+ fMapToPackageFragments = null;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
@@ -171,13 +181,14 @@ abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElem
} else {
DLTKCore.removeElementChangedListener(this);
}
- fInputIsProject= (newInput instanceof IScriptProject);
+ fInputIsProject = (newInput instanceof IScriptProject);
- if(viewer instanceof StructuredViewer)
- fViewer= (StructuredViewer)viewer;
+ if (viewer instanceof StructuredViewer)
+ fViewer = (StructuredViewer) viewer;
}
- abstract protected void processDelta(IModelElementDelta delta) throws ModelException;
+ abstract protected void processDelta(IModelElementDelta delta)
+ throws ModelException;
/*
* @since 3.0
@@ -185,14 +196,15 @@ abstract class LogicalPackagesProvider implements IPropertyChangeListener, IElem
protected boolean isClassPathChange(IModelElementDelta delta) {
// need to test the flags only for package fragment roots
- if (delta.getElement().getElementType() != IModelElement.PROJECT_FRAGMENT )
+ if (delta.getElement()
+ .getElementType() != IModelElement.PROJECT_FRAGMENT)
return false;
- int flags= delta.getFlags();
- return (delta.getKind() == IModelElementDelta.CHANGED &&
- ((flags & IModelElementDelta.F_ADDED_TO_BUILDPATH) != 0) ||
- ((flags & IModelElementDelta.F_REMOVED_FROM_BUILDPATH) != 0) ||
- ((flags & IModelElementDelta.F_REORDER) != 0));
+ int flags = delta.getFlags();
+ return (delta.getKind() == IModelElementDelta.CHANGED
+ && ((flags & IModelElementDelta.F_ADDED_TO_BUILDPATH) != 0)
+ || ((flags & IModelElementDelta.F_REMOVED_FROM_BUILDPATH) != 0)
+ || ((flags & IModelElementDelta.F_REORDER) != 0));
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesView.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesView.java
index ac3a5a9bc..305cf3b81 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesView.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesView.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
@@ -66,8 +66,8 @@ public class PackagesView extends ScriptBrowsingPart {
private static final int LIST_VIEW_STATE = 0;
private static final int TREE_VIEW_STATE = 1;
- private static class StatusBarUpdater4LogicalPackage extends
- StatusBarUpdater {
+ private static class StatusBarUpdater4LogicalPackage
+ extends StatusBarUpdater {
private StatusBarUpdater4LogicalPackage(
IStatusLineManager statusLineManager) {
@@ -86,9 +86,11 @@ public class PackagesView extends ScriptBrowsingPart {
return super.formatMessage(sel);
}
- private String formatLogicalPackageMessage(LogicalPackage logicalPackage) {
+ private String formatLogicalPackageMessage(
+ LogicalPackage logicalPackage) {
IScriptFolder[] fragments = logicalPackage.getScriptFolders();
- StringBuffer buf = new StringBuffer(logicalPackage.getElementName());
+ StringBuffer buf = new StringBuffer(
+ logicalPackage.getElementName());
buf.append(ScriptElementLabels.CONCAT_STRING);
String message = ""; //$NON-NLS-1$
boolean firstTime = true;
@@ -97,10 +99,8 @@ public class PackagesView extends ScriptBrowsingPart {
IModelElement element = fragment.getParent();
if (element instanceof IProjectFragment) {
IProjectFragment root = (IProjectFragment) element;
- String label = ScriptElementLabels
- .getDefault()
- .getElementLabel(
- root,
+ String label = ScriptElementLabels.getDefault()
+ .getElementLabel(root,
ScriptElementLabels.DEFAULT_QUALIFIED
| ScriptElementLabels.ROOT_QUALIFIED);
if (firstTime) {
@@ -109,7 +109,7 @@ public class PackagesView extends ScriptBrowsingPart {
} else
message = Messages.format(
ScriptBrowsingMessages.StatusBar_concat,
- new String[] { message, label });
+ message, label);
}
}
buf.append(message);
@@ -145,15 +145,18 @@ public class PackagesView extends ScriptBrowsingPart {
protected NonScriptElementFilter createNonJavaElementFilter() {
return new NonScriptElementFilter() {
@Override
- public boolean select(Viewer viewer, Object parent, Object element) {
+ public boolean select(Viewer viewer, Object parent,
+ Object element) {
return ((element instanceof IModelElement)
- || (element instanceof LogicalPackage) || (element instanceof IFolder));
+ || (element instanceof LogicalPackage)
+ || (element instanceof IFolder));
}
};
}
@Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
+ public void init(IViewSite site, IMemento memento)
+ throws PartInitException {
super.init(site, memento);
// this must be created before all actions and filters
fWrappedViewer = new PackageViewerWrapper();
@@ -165,12 +168,12 @@ public class PackagesView extends ScriptBrowsingPart {
// read state from the preference store
IPreferenceStore store = DLTKUIPlugin.getDefault()
.getPreferenceStore();
- fCurrViewState = store.getInt(this.getViewSite().getId()
- + TAG_VIEW_STATE);
+ fCurrViewState = store
+ .getInt(this.getViewSite().getId() + TAG_VIEW_STATE);
} else {
// restore from memento
- Integer integer = memento.getInteger(this.getViewSite().getId()
- + TAG_VIEW_STATE);
+ Integer integer = memento
+ .getInteger(this.getViewSite().getId() + TAG_VIEW_STATE);
if ((integer == null) || !isValidState(integer.intValue())) {
fCurrViewState = LIST_VIEW_STATE;
} else
@@ -195,7 +198,9 @@ public class PackagesView extends ScriptBrowsingPart {
/*
* (non-Javadoc)
*
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.eclipse.swt.widgets.Composite)
+ * @see
+ * org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#createViewer(org.
+ * eclipse.swt.widgets.Composite)
*/
@Override
protected StructuredViewer createViewer(Composite parent) {
@@ -241,20 +246,20 @@ public class PackagesView extends ScriptBrowsingPart {
*/
@Override
protected IContentProvider createContentProvider() {
- if (isInListState())
- return new PackagesViewFlatContentProvider(fWrappedViewer
- .getViewer());
- else
- return new PackagesViewHierarchicalContentProvider(fWrappedViewer
- .getViewer());
+ if (isInListState()) {
+ return new PackagesViewFlatContentProvider(
+ fWrappedViewer.getViewer());
+ }
+ return new PackagesViewHierarchicalContentProvider(
+ fWrappedViewer.getViewer());
}
@Override
protected ScriptUILabelProvider createLabelProvider() {
- if (isInListState())
+ if (isInListState()) {
return createListLabelProvider();
- else
- return createTreeLabelProvider();
+ }
+ return createTreeLabelProvider();
}
private ScriptUILabelProvider createTreeLabelProvider() {
@@ -284,23 +289,23 @@ public class PackagesView extends ScriptBrowsingPart {
}
/**
- * Answers if the given <code>element</code> is a valid input for this
- * part.
+ * Answers if the given <code>element</code> is a valid input for this part.
*
* @param element
- * the object to test
+ * the object to test
* @return <true> if the given element is a valid input
*/
@Override
protected boolean isValidInput(Object element) {
if (element instanceof IScriptProject
- || (element instanceof IProjectFragment && ((IModelElement) element)
- .getElementName() != IProjectFragment.DEFAULT_PACKAGE_ROOT)) {
+ || (element instanceof IProjectFragment
+ && ((IModelElement) element)
+ .getElementName() != IProjectFragment.DEFAULT_PACKAGE_ROOT)) {
IScriptProject jProject = ((IModelElement) element)
.getScriptProject();
if (jProject != null)
- return DLTKLanguageManager.hasScriptNature(jProject
- .getProject());
+ return DLTKLanguageManager
+ .hasScriptNature(jProject.getProject());
}
return false;
}
@@ -310,7 +315,7 @@ public class PackagesView extends ScriptBrowsingPart {
* part.
*
* @param element
- * the object to test
+ * the object to test
* @return <true> if the given element is a valid element
*/
@Override
@@ -327,7 +332,9 @@ public class PackagesView extends ScriptBrowsingPart {
/*
* (non-Javadoc)
*
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#findElementToSelect(org.eclipse.jdt.core.IJavaElement)
+ * @see
+ * org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#findElementToSelect
+ * (org.eclipse.jdt.core.IJavaElement)
*/
@Override
protected IModelElement findElementToSelect(IModelElement je) {
@@ -346,9 +353,6 @@ public class PackagesView extends ScriptBrowsingPart {
}
}
- /*
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#setInput(java.lang.Object)
- */
@Override
protected void setInput(Object input) {
setViewerWrapperInput(input);
@@ -402,8 +406,8 @@ public class PackagesView extends ScriptBrowsingPart {
if (element instanceof LogicalPackage) {
LogicalPackage cp = (LogicalPackage) element;
return super.category(cp.getScriptFolders()[0]);
- } else
- return super.category(element);
+ }
+ return super.category(element);
}
@Override
@@ -518,14 +522,12 @@ public class PackagesView extends ScriptBrowsingPart {
private void switchViewer(int state) {
// Indicate which viewer is to be used
- if (fCurrViewState == state)
+ if (fCurrViewState == state) {
return;
- else {
- fCurrViewState = state;
- IPreferenceStore store = DLTKUIPlugin.getDefault()
- .getPreferenceStore();
- store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
}
+ fCurrViewState = state;
+ IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
+ store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
// get the information from the existing viewer
StructuredViewer viewer = fWrappedViewer.getViewer();
@@ -559,8 +561,8 @@ public class PackagesView extends ScriptBrowsingPart {
private void createSelectAllAction() {
IActionBars actionBars = getViewSite().getActionBars();
if (isInListState()) {
- fSelectAllAction = new SelectAllAction((TableViewer) fWrappedViewer
- .getViewer());
+ fSelectAllAction = new SelectAllAction(
+ (TableViewer) fWrappedViewer.getViewer());
actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
fSelectAllAction);
} else {
@@ -579,10 +581,10 @@ public class PackagesView extends ScriptBrowsingPart {
if (je == null)
return null;
if (je.getElementType() == IModelElement.PROJECT_FRAGMENT
- || je.getElementType() == IModelElement.SCRIPT_PROJECT)
+ || je.getElementType() == IModelElement.SCRIPT_PROJECT) {
return findInputForJavaElement(je, true);
- else
- return findInputForJavaElement(je, false);
+ }
+ return findInputForJavaElement(je, false);
}
@@ -596,7 +598,8 @@ public class PackagesView extends ScriptBrowsingPart {
// don't update if input must be project (i.e. project is used as
// source folder)
if (canChangeInputType)
- fLastInputWasProject = je.getElementType() == IModelElement.SCRIPT_PROJECT;
+ fLastInputWasProject = je
+ .getElementType() == IModelElement.SCRIPT_PROJECT;
return je;
} else if (fLastInputWasProject) {
IProjectFragment packageFragmentRoot = (IProjectFragment) je
@@ -617,15 +620,16 @@ public class PackagesView extends ScriptBrowsingPart {
@Override
protected DecoratingModelLabelProvider createDecoratingLabelProvider(
ScriptUILabelProvider provider) {
- return new DecoratingModelLabelProvider(provider, false, isInListState()) {
+ return new DecoratingModelLabelProvider(provider, false,
+ isInListState()) {
@Override
public String getText(Object element) {
if (element instanceof LogicalPackage) {
LogicalPackage el = (LogicalPackage) element;
return super.getText(el.getScriptFolders()[0]);
- } else
- return super.getText(element);
+ }
+ return super.getText(element);
}
@Override
@@ -644,8 +648,8 @@ public class PackagesView extends ScriptBrowsingPart {
image = decoratedImage;
}
return image;
- } else
- return super.getImage(element);
+ }
+ return super.getImage(element);
}
};
@@ -655,7 +659,8 @@ public class PackagesView extends ScriptBrowsingPart {
* Overridden from JavaBrowsingPart to handel LogicalPackages and tree
* structure.
*
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#adjustInputAndSetSelection(org.eclipse.jdt.core.IJavaElement)
+ * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#
+ * adjustInputAndSetSelection(org.eclipse.jdt.core.IJavaElement)
*/
void adjustInputAndSetSelection(IModelElement je) {
@@ -664,8 +669,8 @@ public class PackagesView extends ScriptBrowsingPart {
.getContentProvider();
Object elementToSelect = jElementToSelect;
- if (jElementToSelect != null
- && jElementToSelect.getElementType() == IModelElement.SCRIPT_FOLDER) {
+ if (jElementToSelect != null && jElementToSelect
+ .getElementType() == IModelElement.SCRIPT_FOLDER) {
IScriptFolder pkgFragment = (IScriptFolder) jElementToSelect;
elementToSelect = p.findLogicalPackage(pkgFragment);
if (elementToSelect == null)
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewFlatContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewFlatContentProvider.java
index a9419aa99..62b14d82d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewFlatContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewFlatContentProvider.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
@@ -39,11 +39,6 @@ class PackagesViewFlatContentProvider extends LogicalPackagesProvider
super(viewer);
}
- /*
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
- * Object)
- */
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IModelElement) {
@@ -61,8 +56,8 @@ class PackagesViewFlatContentProvider extends LogicalPackagesProvider
fMapToLogicalPackage.clear();
fMapToPackageFragments.clear();
return combineSamePackagesIntoLogialPackages(children);
- } else
- return children;
+ }
+ return children;
case IModelElement.PROJECT_FRAGMENT:
fMapToLogicalPackage.clear();
@@ -177,10 +172,10 @@ class PackagesViewFlatContentProvider extends LogicalPackagesProvider
// PackageFragmentRoot)
private Object findElementToRefresh(IScriptFolder fragment) {
if (fViewer.testFindItem(fragment) == null) {
- if (fInputIsProject)
+ if (fInputIsProject) {
return fragment.getScriptProject();
- else
- return fragment.getParent();
+ }
+ return fragment.getParent();
}
return fragment;
}
@@ -257,10 +252,9 @@ class PackagesViewFlatContentProvider extends LogicalPackagesProvider
postAdd(fragment);
}
return;
- } else {
- fMapToPackageFragments.remove(key);
- postRemove(frag);
}
+ fMapToPackageFragments.remove(key);
+ postRemove(frag);
}
private void postRefresh(final Object element) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewHierarchicalContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewHierarchicalContentProvider.java
index 27bb6b5d7..c22798d97 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewHierarchicalContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewHierarchicalContentProvider.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
@@ -95,9 +95,8 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider
if (logicalPackages.length > 0)
folders.addAll(Arrays.asList(logicalPackages));
return folders.toArray();
- } else {
- return logicalPackages;
}
+ return logicalPackages;
}
case IModelElement.PROJECT_FRAGMENT: {
@@ -301,15 +300,14 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider
if (parent instanceof IScriptFolder) {
IScriptFolder pkgFragment = (IScriptFolder) parent;
LogicalPackage logicalPkg = findLogicalPackage(pkgFragment);
- if (logicalPkg != null)
+ if (logicalPkg != null) {
return logicalPkg;
- else {
- LogicalPackage lp = createLogicalPackage(pkgFragment);
- if (lp == null)
- return pkgFragment;
- else
- return lp;
}
+ LogicalPackage lp = createLogicalPackage(pkgFragment);
+ if (lp == null) {
+ return pkgFragment;
+ }
+ return lp;
}
return parent;
@@ -321,17 +319,16 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider
if (parent instanceof IScriptFolder) {
IScriptFolder pkgFragment = (IScriptFolder) parent;
LogicalPackage logicalPkg = findLogicalPackage(pkgFragment);
- if (logicalPkg != null)
+ if (logicalPkg != null) {
return logicalPkg;
- else {
- LogicalPackage lp = createLogicalPackage(pkgFragment);
- if (lp == null)
- return pkgFragment;
- else
- return lp;
}
- } else
- return fragment.getScriptProject();
+ LogicalPackage lp = createLogicalPackage(pkgFragment);
+ if (lp == null) {
+ return pkgFragment;
+ }
+ return lp;
+ }
+ return fragment.getScriptProject();
} else if (element instanceof IFolder) {
IFolder folder = (IFolder) element;
IResource res = folder.getParent();
@@ -339,9 +336,8 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider
IModelElement el = DLTKCore.create(res);
if (el != null) {
return el;
- } else {
- return res;
}
+ return res;
}
} catch (Exception e) {
@@ -400,19 +396,17 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider
IProjectFragment root = (IProjectFragment) parent;
if (root.isArchive() || !fragment.exists()) {
return findNextLevelParentByElementName(fragment);
- } else {
- IResource resource = fragment.getUnderlyingResource();
- if ((resource != null) && (resource instanceof IFolder)) {
- IFolder folder = (IFolder) resource;
- IResource res = folder.getParent();
-
- IModelElement el = DLTKCore.create(res);
- if (el != null) {
- return el;
- } else {
- return res;
- }
+ }
+ IResource resource = fragment.getUnderlyingResource();
+ if ((resource != null) && (resource instanceof IFolder)) {
+ IFolder folder = (IFolder) resource;
+ IResource res = folder.getParent();
+
+ IModelElement el = DLTKCore.create(res);
+ if (el != null) {
+ return el;
}
+ return res;
}
}
return parent;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewLabelProvider.java
index c8d318579..1a1ffc0d3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/PackagesViewLabelProvider.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,15 +38,16 @@ class PackagesViewLabelProvider extends AppearanceAwareLabelProvider {
private TreeHierarchyLayoutProblemsDecorator fDecorator;
PackagesViewLabelProvider(int state) {
- this(state, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
- | ScriptElementLabels.P_COMPRESSED,
+ this(state,
+ AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
+ | ScriptElementLabels.P_COMPRESSED,
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
| ScriptElementImageProvider.SMALL_ICONS);
}
PackagesViewLabelProvider(int state, long textFlags, int imageFlags) {
- super(textFlags, imageFlags, DLTKUIPlugin.getDefault()
- .getPreferenceStore());
+ super(textFlags, imageFlags,
+ DLTKUIPlugin.getDefault().getPreferenceStore());
Assert.isTrue(isValidState(state));
fViewState = state;
@@ -111,10 +112,10 @@ class PackagesViewLabelProvider extends AppearanceAwareLabelProvider {
}
private String getText(IScriptFolder fragment) {
- if (isFlatView())
+ if (isFlatView()) {
return getFlatText(fragment);
- else
- return getHierarchicalText(fragment);
+ }
+ return getHierarchicalText(fragment);
}
private String getText(LogicalPackage logicalPackage) {
@@ -135,10 +136,10 @@ class PackagesViewLabelProvider extends AppearanceAwareLabelProvider {
return super.getText(fragment);
}
IResource res = fragment.getResource();
- if (res != null && !(res.getType() == IResource.FILE))
+ if (res != null && !(res.getType() == IResource.FILE)) {
return decorateText(res.getName(), fragment);
- else
- return decorateText(calculateName(fragment), fragment);
+ }
+ return decorateText(calculateName(fragment), fragment);
}
private String calculateName(IScriptFolder fragment) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ProjectsView.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ProjectsView.java
index dcc893da5..c7e3292fa 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ProjectsView.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ProjectsView.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
@@ -119,7 +119,7 @@ public class ProjectsView extends ScriptBrowsingPart {
* Answers if the given <code>element</code> is a valid input for this part.
*
* @param element
- * the object to test
+ * the object to test
* @return <true> if the given element is a valid input
*/
@Override
@@ -132,7 +132,7 @@ public class ProjectsView extends ScriptBrowsingPart {
* part.
*
* @param element
- * the object to test
+ * the object to test
* @return <true> if the given element is a valid element
*/
@Override
@@ -155,7 +155,7 @@ public class ProjectsView extends ScriptBrowsingPart {
* Finds the element which has to be selected in this part.
*
* @param je
- * the Java element which has the focus
+ * the Java element which has the focus
* @return the element to select
*/
@Override
@@ -170,10 +170,10 @@ public class ProjectsView extends ScriptBrowsingPart {
return je;
case IModelElement.PROJECT_FRAGMENT:
if (je.getElementName()
- .equals(IProjectFragment.DEFAULT_PACKAGE_ROOT))
+ .equals(IProjectFragment.DEFAULT_PACKAGE_ROOT)) {
return je.getParent();
- else
- return je;
+ }
+ return je;
default:
return findElementToSelect(je.getParent());
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
index 865fe6479..c48d635ee 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
@@ -687,11 +687,10 @@ public abstract class ScriptBrowsingPart extends ViewPart
Object input = getViewer().getInput();
if (input == null)
return false;
- if (input instanceof Collection)
+ if (input instanceof Collection) {
return ((Collection) input).contains(element);
- else
- return input.equals(element);
-
+ }
+ return input.equals(element);
}
private boolean isInputResetBy(Object newInput, Object input,
@@ -702,11 +701,10 @@ public abstract class ScriptBrowsingPart extends ViewPart
if (input instanceof IModelElement && newInput instanceof IModelElement)
return getTypeComparator().compare(newInput, input) > 0;
- if ((newInput instanceof List) && (part instanceof PackagesView))
+ if ((newInput instanceof List) && (part instanceof PackagesView)) {
return true;
-
- else
- return false;
+ }
+ return false;
}
private boolean isInputResetBy(IWorkbenchPart part) {
@@ -722,10 +720,10 @@ public abstract class ScriptBrowsingPart extends ViewPart
partInput = ((Collection) partInput).iterator().next();
if (thisInput instanceof IModelElement
- && partInput instanceof IModelElement)
+ && partInput instanceof IModelElement) {
return getTypeComparator().compare(partInput, thisInput) > 0;
- else
- return true;
+ }
+ return true;
}
protected boolean isAncestorOf(Object ancestor, Object element) {
@@ -748,11 +746,11 @@ public abstract class ScriptBrowsingPart extends ViewPart
private boolean internalIsAncestorOf(IModelElement ancestor,
IModelElement element) {
- if (element != null)
+ if (element != null) {
return element.equals(ancestor)
|| internalIsAncestorOf(ancestor, element.getParent());
- else
- return false;
+ }
+ return false;
}
private boolean isSearchResultView(IWorkbenchPart part) {
@@ -1191,26 +1189,26 @@ public abstract class ScriptBrowsingPart extends ViewPart
.getAdapter(IModelElement.class);
if (je == null && firstElement instanceof IFile) {
IContainer parent = ((IFile) firstElement).getParent();
- if (parent != null)
+ if (parent != null) {
return parent.getAdapter(IModelElement.class);
- else
- return null;
- } else
- return je;
-
- } else
- return firstElement;
+ }
+ return null;
+ }
+ return je;
+ }
+ return firstElement;
}
Object currentInput = getViewer().getInput();
List elements = new ArrayList();
- if (currentInput == null || !currentInput
- .equals(findInputForJavaElement((IModelElement) firstElement)))
+ if (currentInput == null || !currentInput.equals(
+ findInputForJavaElement((IModelElement) firstElement))) {
if (iter.hasNext() && selection instanceof StructuredSelection) {
// multi-selection and view is empty
return ((StructuredSelection) selection).toList();
- } else
- // OK: single selection and view is empty
- return firstElement;
+ }
+ // OK: single selection and view is empty
+ return firstElement;
+ }
// be nice to multi-selection
while (iter.hasNext()) {
@@ -1343,15 +1341,14 @@ public abstract class ScriptBrowsingPart extends ViewPart
ISourceModule unit = manager.getWorkingCopy(input);
if (unit != null)
try {
- if (unit.isConsistent())
+ if (unit.isConsistent()) {
return unit.getElementAt(offset);
- else {
- /*
- * XXX: We should set the selection later when the CU is
- * reconciled. see
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
- */
}
+ /*
+ * XXX: We should set the selection later when the CU is
+ * reconciled. see
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
+ */
} catch (ModelException ex) {
// fall through
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
index 7a9a02360..b5eed1212 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
@@ -91,10 +91,9 @@ public class ExtendedClassesView extends ViewPart
if (affectedChildren[i].getElement()
.getElementType() == IModelElement.TYPE) {
return true;
- } else {
- if (typesChanged(affectedChildren[i])) {
- return true;
- }
+ }
+ if (typesChanged(affectedChildren[i])) {
+ return true;
}
}
return false;
@@ -323,25 +322,26 @@ public class ExtendedClassesView extends ViewPart
.getAdapter(IModelElement.class);
if (je == null && firstElement instanceof IFile) {
IContainer parent = ((IFile) firstElement).getParent();
- if (parent != null)
+ if (parent != null) {
return parent.getAdapter(IModelElement.class);
- else
- return null;
- } else
- return je;
+ }
+ return null;
+ }
+ return je;
- } else
- return firstElement;
+ }
+ return firstElement;
}
Object currentInput = browsingPane.getInput();
List elements = new ArrayList();
- if (currentInput == null || !currentInput.equals(firstElement))
+ if (currentInput == null || !currentInput.equals(firstElement)) {
if (iter.hasNext() && selection instanceof StructuredSelection) {
// multi-selection and view is empty
return ((StructuredSelection) selection).toList();
- } else
- // OK: single selection and view is empty
- return firstElement;
+ }
+ // OK: single selection and view is empty
+ return firstElement;
+ }
// be nice to multi-selection
while (iter.hasNext()) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/MultiSelectionListViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/MultiSelectionListViewer.java
index 6a636fad2..0f6934015 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/MultiSelectionListViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/MultiSelectionListViewer.java
@@ -108,9 +108,8 @@ public class MultiSelectionListViewer extends ScrolledComposite {
public Object[] getElements(Object inputElement) {
if (controlIndex == 0) {
return contentProvider.getElements(input);
- } else {
- return getElementsFrom(this.controlIndex - 1);
}
+ return getElementsFrom(this.controlIndex - 1);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/dialogs/FilteredTypesSelectionDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/dialogs/FilteredTypesSelectionDialog.java
index 6f866b3a4..b5e90ca2b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/dialogs/FilteredTypesSelectionDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/dialogs/FilteredTypesSelectionDialog.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
@@ -138,24 +138,26 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
* Creates new FilteredTypesSelectionDialog instance
*
* @param parent
- * shell to parent the dialog on
+ * shell to parent the dialog on
* @param multi
- * <code>true</code> if multiple selection is allowed
+ * <code>true</code> if multiple selection is
+ * allowed
* @param context
- * context used to execute long-running operations associated
- * with this dialog
+ * context used to execute long-running operations
+ * associated with this dialog
* @param scope
- * scope used when searching for types
+ * scope used when searching for types
* @param elementKinds
- * flags defining nature of searched elements; the only valid
- * values are: <code>IJavaSearchConstants.TYPE</code>
- * <code>IJavaSearchConstants.ANNOTATION_TYPE</code>
- * <code>IJavaSearchConstants.INTERFACE</code>
- * <code>IJavaSearchConstants.ENUM</code>
- * <code>IJavaSearchConstants.CLASS_AND_INTERFACE</code>
- * <code>IJavaSearchConstants.CLASS_AND_ENUM</code>. Please note
- * that the bitwise OR combination of the elementary constants is
- * not supported.
+ * flags defining nature of searched elements; the
+ * only valid values are:
+ * <code>IJavaSearchConstants.TYPE</code>
+ * <code>IJavaSearchConstants.ANNOTATION_TYPE</code>
+ * <code>IJavaSearchConstants.INTERFACE</code>
+ * <code>IJavaSearchConstants.ENUM</code>
+ * <code>IJavaSearchConstants.CLASS_AND_INTERFACE</code>
+ * <code>IJavaSearchConstants.CLASS_AND_ENUM</code>.
+ * Please note that the bitwise OR combination of
+ * the elementary constants is not supported.
*/
public FilteredTypesSelectionDialog(Shell parent, boolean multi,
IRunnableContext context, IDLTKSearchScope scope, int elementKinds,
@@ -167,29 +169,32 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
* Creates new FilteredTypesSelectionDialog instance.
*
* @param shell
- * shell to parent the dialog on
+ * shell to parent the dialog on
* @param multi
- * <code>true</code> if multiple selection is allowed
+ * <code>true</code> if multiple selection is
+ * allowed
* @param context
- * context used to execute long-running operations associated
- * with this dialog
+ * context used to execute long-running operations
+ * associated with this dialog
* @param scope
- * scope used when searching for types. If the scope is
- * <code>null</code>, then workspace is scope is used as default,
- * and the user can choose a working set as scope.
+ * scope used when searching for types. If the scope
+ * is <code>null</code>, then workspace is scope is
+ * used as default, and the user can choose a
+ * working set as scope.
* @param elementKinds
- * flags defining nature of searched elements; the only valid
- * values are: <code>IJavaSearchConstants.TYPE</code>
- * <code>IJavaSearchConstants.ANNOTATION_TYPE</code>
- * <code>IJavaSearchConstants.INTERFACE</code>
- * <code>IJavaSearchConstants.ENUM</code>
- * <code>IJavaSearchConstants.CLASS_AND_INTERFACE</code>
- * <code>IJavaSearchConstants.CLASS_AND_ENUM</code>. Please note
- * that the bitwise OR combination of the elementary constants is
- * not supported.
+ * flags defining nature of searched elements; the
+ * only valid values are:
+ * <code>IJavaSearchConstants.TYPE</code>
+ * <code>IJavaSearchConstants.ANNOTATION_TYPE</code>
+ * <code>IJavaSearchConstants.INTERFACE</code>
+ * <code>IJavaSearchConstants.ENUM</code>
+ * <code>IJavaSearchConstants.CLASS_AND_INTERFACE</code>
+ * <code>IJavaSearchConstants.CLASS_AND_ENUM</code>.
+ * Please note that the bitwise OR combination of
+ * the elementary constants is not supported.
* @param extension
- * an extension of the standard type selection dialog; See
- * {@link TypeSelectionExtension}
+ * an extension of the standard type selection
+ * dialog; See {@link TypeSelectionExtension}
*/
public FilteredTypesSelectionDialog(Shell shell, boolean multi,
IRunnableContext context, IDLTKSearchScope scope, int elementKinds,
@@ -240,7 +245,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
* Adds or replaces subtitle of the dialog
*
* @param text
- * the new subtitle for this dialog
+ * the new subtitle for this dialog
*/
private void setSubtitle(String text) {
if (text == null || text.length() == 0) {
@@ -248,7 +253,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
} else {
getShell().setText(Messages.format(
DLTKUIMessages.FilteredTypeSelectionDialog_titleFormat,
- new String[] { fTitle, text }));
+ fTitle, text));
}
}
@@ -394,8 +399,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
ScriptElementLabels.ALL_FULLY_QUALIFIED);
String message = Messages.format(
DLTKUIMessages.FilteredTypesSelectionDialog_dialogMessage,
- new String[] { typeInfo.getFullyQualifiedName(),
- containerName });
+ typeInfo.getFullyQualifiedName(), containerName);
MessageDialog.openError(getShell(), fTitle, message);
getSelectionHistory().remove(typeInfo);
}
@@ -439,7 +443,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
* Sets a new validator.
*
* @param validator
- * the new validator
+ * the new validator
*/
public void setValidator(ISelectionStatusValidator validator) {
fValidator = validator;
@@ -600,16 +604,16 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
null);
Object[] elements = { type };
return fValidator.validate(elements);
- } else
- return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(),
- IStatus.OK, "", null); //$NON-NLS-1$
+ }
+ return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), IStatus.OK,
+ "", null); //$NON-NLS-1$
}
/**
* Sets search scope used when searching for types.
*
* @param scope
- * the new scope
+ * the new scope
*/
private void setSearchScope(IDLTKSearchScope scope) {
fSearchScope = scope;
@@ -1124,9 +1128,10 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog
* Set filter to "match everything" mode.
*
* @param matchEverything
- * if <code>true</code>, {@link #matchItem(Object)} always
- * returns true. If <code>false</code>, the filter is
- * enabled.
+ * if <code>true</code>,
+ * {@link #matchItem(Object)} always returns
+ * true. If <code>false</code>, the filter is
+ * enabled.
*/
public void setMatchEverythingMode(boolean matchEverything) {
this.fMatchEverything = matchEverything;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/documentation/ScriptDocumentationAccess.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/documentation/ScriptDocumentationAccess.java
index 0875fe0e0..39d87a62e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/documentation/ScriptDocumentationAccess.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/documentation/ScriptDocumentationAccess.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
@@ -133,16 +133,18 @@ public class ScriptDocumentationAccess {
* <code>true</code>)
*
* @param member
- * The member to get documentation for.
+ * The member to get documentation for.
* @param allowInherited
- * For procedures and methods: if member doesn't have it's own
- * documentation, look into parent types methods.
+ * For procedures and methods: if member doesn't
+ * have it's own documentation, look into parent
+ * types methods.
* @param allowExternal
- * Allows external documentation like man-pages.
+ * Allows external documentation like man-pages.
* @return Reader for a content, or <code>null</code> if no documentation is
* found.
* @throws ModelException
- * is thrown when the elements documentation can not be accessed
+ * is thrown when the elements documentation can
+ * not be accessed
* @since 3.0
*/
public static Reader getHTMLContentReader(String nature,
@@ -223,11 +225,12 @@ public class ScriptDocumentationAccess {
* The content does contain HTML code describing member.
*
* @param content
- * The keyword to find.
+ * The keyword to find.
* @return Reader for a content, or <code>null</code> if no documentation is
* found.
* @throws ModelException
- * is thrown when the elements documentation can not be accessed
+ * is thrown when the elements documentation can
+ * not be accessed
*/
@Deprecated
public static Reader getHTMLContentReader(String nature,
@@ -252,9 +255,8 @@ public class ScriptDocumentationAccess {
final IDocumentationResponse response = ext
.describeKeyword(keyword, context);
return DocumentationUtils.getReader(response);
- } else {
- return provider.getInfo(keyword);
}
+ return provider.getInfo(keyword);
});
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/highlighting/ASTSemanticHighlighter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/highlighting/ASTSemanticHighlighter.java
index d5ce43258..25b48714f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/highlighting/ASTSemanticHighlighter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/highlighting/ASTSemanticHighlighter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -20,8 +20,8 @@ import org.eclipse.dltk.core.SourceParserUtil;
/**
* Abstract base class for the semantic highlighters operating on the AST tree.
*/
-public abstract class ASTSemanticHighlighter extends
- AbstractSemanticHighlighter {
+public abstract class ASTSemanticHighlighter
+ extends AbstractSemanticHighlighter {
/**
* @param code
@@ -32,9 +32,8 @@ public abstract class ASTSemanticHighlighter extends
throws ModelException {
if (code instanceof ISourceModule) {
return parseSourceModule((ISourceModule) code);
- } else {
- return parseSourceCode(code);
}
+ return parseSourceCode(code);
}
private IModuleDeclaration parseSourceCode(IModuleSource code) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/saveparticipant/SaveParticipantRegistry.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/saveparticipant/SaveParticipantRegistry.java
index ffa4f7c48..caacda41c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/saveparticipant/SaveParticipantRegistry.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/editor/saveparticipant/SaveParticipantRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -70,7 +70,8 @@ public final class SaveParticipantRegistry
* the given context.
*
* @param context
- * the context from which to retrieve the settings from, not null
+ * the context from which to retrieve the settings from,
+ * not null
* @return the current enabled post save listeners according to the
* preferences
*/
@@ -92,9 +93,8 @@ public final class SaveParticipantRegistry
}
if (result == null) {
return EMPTY_ARRAY;
- } else {
- return result.toArray(new IPostSaveListener[result.size()]);
}
+ return result.toArray(new IPostSaveListener[result.size()]);
}
@Override
@@ -107,10 +107,10 @@ public final class SaveParticipantRegistry
* about the changed region in this save cycle.
*
* @param unit
- * the unit which is about to be saved
+ * the unit which is about to be saved
* @return true if the change regions need do be determined
* @throws CoreException
- * if something went wrong
+ * if something went wrong
*/
public static boolean isChangedRegionsRequired(final ISourceModule unit,
IPostSaveListener[] listeners) throws CoreException {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/environment/EnvironmentContainer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/environment/EnvironmentContainer.java
index 044e3ee21..6f67614c0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/environment/EnvironmentContainer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/environment/EnvironmentContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -147,9 +147,8 @@ public class EnvironmentContainer {
final IEnvironment environment = environments.get(environmentId);
if (environment != null) {
return environment.getName();
- } else {
- return "(" + environmentId + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
+ return "(" + environmentId + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/AbstractDocumentationView.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/AbstractDocumentationView.java
index a80473d8e..1b39201cd 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/AbstractDocumentationView.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/AbstractDocumentationView.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
@@ -124,9 +124,9 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Creates the action.
*
* @param control
- * the widget
+ * the widget
* @param selectionProvider
- * the selection provider
+ * the selection provider
*/
public SelectAllAction(Control control,
SelectionProvider selectionProvider) {
@@ -173,7 +173,7 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Creates a new selection provider.
*
* @param control
- * the widget
+ * the widget
*/
public SelectionProvider(Control control) {
fControl = control;
@@ -220,11 +220,10 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
IDocument document = new Document(
((StyledText) fControl).getSelectionText());
return new TextSelection(document, 0, document.getLength());
- } else {
- // FIXME: see
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
- return StructuredSelection.EMPTY;
}
+ // FIXME: see
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022
+ return StructuredSelection.EMPTY;
}
@Override
@@ -432,7 +431,7 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Returns the doc in HTML format.
*
* @param result
- * the Script elements for which to get the Javadoc
+ * the Script elements for which to get the Javadoc
* @return a string with the Javadoc in HTML format.
*/
private String getScriptdocHtml(KeywordInput keyword) {
@@ -459,7 +458,7 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Returns the Javadoc in HTML format.
*
* @param result
- * the Script elements for which to get the Javadoc
+ * the Script elements for which to get the Javadoc
* @return a string with the Javadoc in HTML format.
*/
private String getScriptdocHtmlDetailed(Object[] result) {
@@ -501,7 +500,7 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Returns the Javadoc in HTML format.
*
* @param result
- * the Script elements for which to get the Javadoc
+ * the Script elements for which to get the Javadoc
* @return a string with the Javadoc in HTML format.
*/
private String getScriptdocHtmlList(IModelElement[] result) {
@@ -522,7 +521,7 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Returns the Javadoc in HTML format.
*
* @param result
- * the Script elements for which to get the Javadoc
+ * the Script elements for which to get the Javadoc
* @return a string with the Javadoc in HTML format.
*/
private String getScriptdocHtml(IModelElement curr) {
@@ -583,25 +582,24 @@ public abstract class AbstractDocumentationView extends AbstractInfoView {
* Gets the label for the given member.
*
* @param member
- * the Script member
+ * the Script member
* @return a string containing the member's label
*/
private String getInfoText(Object member) {
if (member instanceof IModelElement) {
return ScriptElementLabels.getDefault()
.getElementLabel((IModelElement) member, LABEL_FLAGS);
- } else {
- // TODO
- return null;
}
+ // TODO
+ return null;
}
@Override
protected Control getControl() {
- if (fIsUsingBrowserWidget)
+ if (fIsUsingBrowserWidget) {
return fBrowser;
- else
- return fText;
+ }
+ return fText;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/ModelElementArray.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/ModelElementArray.java
index bb9b06386..a3400adb1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/ModelElementArray.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/ModelElementArray.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 xored software, Inc. and others.
+ * Copyright (c) 2008, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -51,9 +51,8 @@ public class ModelElementArray {
if (obj instanceof ModelElementArray) {
final ModelElementArray other = (ModelElementArray) obj;
return Arrays.equals(elements, other.elements);
- } else {
- return false;
}
+ return false;
}
/**
@@ -163,10 +162,10 @@ public class ModelElementArray {
* </p>
*
* @param collection
- * the <code>Collection</code> of values to join together, may be
- * null
+ * the <code>Collection</code> of values to join
+ * together, may be null
* @param separator
- * the separator character to use, null treated as ""
+ * the separator character to use, null treated as ""
* @return the joined String, <code>null</code> if null collection input
*/
private static String join(Collection<?> collection, String separator) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/TextSelectionConverter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/TextSelectionConverter.java
index 0c430216d..f83d7eefc 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/TextSelectionConverter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/infoviews/TextSelectionConverter.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.ui.infoviews;
@@ -22,8 +21,8 @@ import org.eclipse.ui.IEditorPart;
/**
* Helper class to convert text selections to Script elements.
- *
- *
+ *
+ *
*/
class TextSelectionConverter {
@@ -33,11 +32,11 @@ class TextSelectionConverter {
/**
* Finds and returns the Script elements for the given editor selection.
- *
+ *
* @param editor
- * the Script editor
+ * the Script editor
* @param selection
- * the text selection
+ * the text selection
* @return the Script elements for the given editor selection
* @throws ModelException
*/
@@ -49,11 +48,11 @@ class TextSelectionConverter {
/**
* Finds and returns the Script element that contains the text selection in
* the given editor.
- *
+ *
* @param editor
- * the Script editor
+ * the Script editor
* @param selection
- * the text selection
+ * the text selection
* @return the Script elements for the given editor selection
* @throws ModelException
*/
@@ -81,8 +80,8 @@ class TextSelectionConverter {
if (cunit.isWorkingCopy())
ScriptModelUtil.reconcile(cunit);
}
- IModelElement[] elements = ((ICodeAssist) input).codeSelect(
- selection.getOffset(), selection.getLength());
+ IModelElement[] elements = ((ICodeAssist) input)
+ .codeSelect(selection.getOffset(), selection.getLength());
if (elements != null && elements.length > 0)
return elements;
}
@@ -96,10 +95,10 @@ class TextSelectionConverter {
if (cunit.isWorkingCopy())
ScriptModelUtil.reconcile(cunit);
IModelElement ref = cunit.getElementAt(selection.getOffset());
- if (ref == null)
+ if (ref == null) {
return input;
- else
- return ref;
+ }
+ return ref;
}
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java
index d95b3861f..2946d1ab4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.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
@@ -187,7 +187,7 @@ public abstract class AbstractConfigurationBlock
* </p>
*
* @param parent
- * the parent composite
+ * the parent composite
* @return the newly created composite
*/
public Composite createSectionComposite(Composite parent) {
@@ -213,7 +213,7 @@ public abstract class AbstractConfigurationBlock
* directly to the returned composite, which has no layout initially.
*
* @param label
- * the display name of the section
+ * the display name of the section
* @return a composite within the expandable section
*/
public Composite createSection(String label) {
@@ -478,17 +478,18 @@ public abstract class AbstractConfigurationBlock
* controls.
*
* @param composite
- * the parent composite
+ * the parent composite
* @param label
- * the text field's label
+ * the text field's label
* @param key
- * the preference key
+ * the preference key
* @param textLimit
- * the text limit
+ * the text limit
* @param indentation
- * the field's indentation
+ * the field's indentation
* @param isNumber
- * <code>true</code> iff this text field is used to edit a number
+ * <code>true</code> iff this text field is used to
+ * edit a number
* @return the controls added
*/
protected Control[] addLabelledTextField(Composite composite, String label,
@@ -685,13 +686,12 @@ public abstract class AbstractConfigurationBlock
SectionManager manager, String label) {
if (manager != null) {
return manager.createSection(label);
- } else {
- Group group = new Group(parent, SWT.SHADOW_NONE);
- group.setText(label);
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- group.setLayoutData(data);
- return group;
}
+ Group group = new Group(parent, SWT.SHADOW_NONE);
+ group.setText(label);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ group.setLayoutData(data);
+ return group;
}
private FontMetrics fFontMetrics;
@@ -705,7 +705,7 @@ public abstract class AbstractConfigurationBlock
* </p>
*
* @param testControl
- * a control from which to obtain the current font
+ * a control from which to obtain the current font
*/
protected void initializeDialogUnits(Control testControl) {
// Compute and store a font metric
@@ -727,7 +727,7 @@ public abstract class AbstractConfigurationBlock
* </p>
*
* @param chars
- * the number of characters
+ * the number of characters
* @return the number of pixels
*/
protected int convertWidthInCharsToPixels(int chars) {
@@ -749,7 +749,7 @@ public abstract class AbstractConfigurationBlock
* </p>
*
* @param chars
- * the number of characters
+ * the number of characters
* @return the number of pixels
*/
protected int convertHeightInCharsToPixels(int chars) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractScriptEditorColoringConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractScriptEditorColoringConfigurationBlock.java
index 64823725c..5ef1e13be 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractScriptEditorColoringConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractScriptEditorColoringConfigurationBlock.java
@@ -257,10 +257,10 @@ public abstract class AbstractScriptEditorColoringConfigurationBlock extends
private class ColorListLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
- if (element instanceof String)
+ if (element instanceof String) {
return (String) element;
- else
- return ((HighlightingColorListItem) element).getDisplayName();
+ }
+ return ((HighlightingColorListItem) element).getDisplayName();
}
}
@@ -312,9 +312,8 @@ public abstract class AbstractScriptEditorColoringConfigurationBlock extends
public Object getParent(Object element) {
if (element instanceof HighlightingColorListItem) {
return ((HighlightingColorListItem) element).getCategory();
- } else {
- return null;
}
+ return null;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/CodeTemplateBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/CodeTemplateBlock.java
index 821b5eb0d..11501e437 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/CodeTemplateBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/CodeTemplateBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -111,9 +111,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
ICodeTemplateCategory category = (ICodeTemplateCategory) element;
if (category.isGroup()) {
return getTemplateContextTypes(category);
- } else {
- return getTemplatesOfCategory(category);
}
+ return getTemplatesOfCategory(category);
} else if (element instanceof TemplateContextType) {
return getTemplatesOfContextType(
((TemplateContextType) element).getId());
@@ -135,9 +134,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
if (category.isGroup()) {
return codeTemplateAccess.getContextTypeRegistry()
.getContextType(contextTypeId);
- } else {
- return category;
}
+ return category;
} else if (element instanceof TemplateContextType) {
return codeTemplateAccess.getCategoryOfContextType(
((TemplateContextType) element).getId());
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/EditTemplateDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/EditTemplateDialog.java
index e1483b046..4d3313912 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/EditTemplateDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/EditTemplateDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -100,9 +100,9 @@ public class EditTemplateDialog extends StatusDialog {
* Creates a new action.
*
* @param viewer
- * the viewer
+ * the viewer
* @param operationCode
- * the opcode
+ * the opcode
*/
public TextViewerAction(ITextViewer viewer, int operationCode) {
fOperationCode = operationCode;
@@ -170,17 +170,20 @@ public class EditTemplateDialog extends StatusDialog {
* Creates a new dialog.
*
* @param parent
- * the shell parent of the dialog
+ * the shell parent of the dialog
* @param template
- * the template to edit
+ * the template to edit
* @param edit
- * whether this is a new template or an existing being edited
+ * whether this is a new template or an
+ * existing being edited
* @param isNameModifiable
- * whether the name of the template may be modified
+ * whether the name of the template may
+ * be modified
* @param isContextTypeModifiable
- * whether the context type of the template may be modified
+ * whether the context type of the
+ * template may be modified
* @param registry
- * the context type registry to use
+ * the context type registry to use
*/
public EditTemplateDialog(IDLTKUILanguageToolkit toolkit, Shell parent,
Template template, boolean edit, boolean isNameModifiable,
@@ -473,10 +476,10 @@ public class EditTemplateDialog extends StatusDialog {
private String getPrefix() {
String id = getContextId();
int idx = getIndex(id);
- if (idx != -1)
+ if (idx != -1) {
return fContextTypes[idx][2];
- else
- return ""; //$NON-NLS-1$
+ }
+ return ""; //$NON-NLS-1$
}
private void initializeActions() {
@@ -640,7 +643,7 @@ public class EditTemplateDialog extends StatusDialog {
* Checks whether the given string is a valid template name.
*
* @param name
- * the string to test
+ * the string to test
* @return <code>true</code> if the name is valid
* @since 3.3.1
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferenceChangeRebuildPrompt.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferenceChangeRebuildPrompt.java
index fe8433f85..bea3a8d2e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferenceChangeRebuildPrompt.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/PreferenceChangeRebuildPrompt.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -16,8 +16,8 @@ import org.eclipse.osgi.util.NLS;
/**
* Default implementation of the {@link IPreferenceChangeRebuildPrompt}
*/
-public class PreferenceChangeRebuildPrompt implements
- IPreferenceChangeRebuildPrompt {
+public class PreferenceChangeRebuildPrompt
+ implements IPreferenceChangeRebuildPrompt {
private String title;
private String message;
@@ -69,9 +69,8 @@ public class PreferenceChangeRebuildPrompt implements
public String getMessage() {
if (messageTemplate == null || messageTemplate.length() == 0) {
return message;
- } else {
- return NLS.bind(messageTemplate, message);
}
+ return NLS.bind(messageTemplate, message);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java
index 2beecaaf3..94f076666 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/TodoTaskConfigurationBlock.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
@@ -68,16 +68,15 @@ public class TodoTaskConfigurationBlock extends AbstractConfigurationBlock {
final TodoTask task = (TodoTask) element;
if (columnIndex == 0) {
return task.name;
- } else {
- if (TodoTask.PRIORITY_HIGH.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
- } else if (TodoTask.PRIORITY_NORMAL.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
- } else if (TodoTask.PRIORITY_LOW.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
- }
- return ""; //$NON-NLS-1$
}
+ if (TodoTask.PRIORITY_HIGH.equals(task.priority)) {
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
+ } else if (TodoTask.PRIORITY_NORMAL.equals(task.priority)) {
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
+ } else if (TodoTask.PRIORITY_LOW.equals(task.priority)) {
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
+ }
+ return ""; //$NON-NLS-1$
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/refactoring/RenameSupport.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/refactoring/RenameSupport.java
index da43810b0..606ef73a3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/refactoring/RenameSupport.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/refactoring/RenameSupport.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
@@ -53,17 +53,18 @@ public class RenameSupport {
* Creates a new rename support for the given {@link IScriptProject}.
*
* @param project
- * the {@link IScriptProject} to be renamed.
+ * the {@link IScriptProject} to be renamed.
* @param newName
- * the project's new name. <code>null</code> is a valid value
- * indicating that no new name is provided.
+ * the project's new name. <code>null</code> is a valid
+ * value indicating that no new name is provided.
* @param flags
- * flags controlling additional parameters. Valid flags are
- * <code>UPDATE_REFERENCES</code> or <code>NONE</code>.
+ * flags controlling additional parameters. Valid flags
+ * are <code>UPDATE_REFERENCES</code> or
+ * <code>NONE</code>.
* @return the {@link RenameSupport}.
* @throws CoreException
- * if an unexpected error occurred while creating the
- * {@link RenameSupport}.
+ * if an unexpected error occurred while creating
+ * the {@link RenameSupport}.
*/
public static RenameSupport create(IScriptProject project, String newName,
int flags) throws CoreException {
@@ -82,14 +83,15 @@ public class RenameSupport {
* Creates a new rename support for the given {@link IProjectFragment}.
*
* @param root
- * the {@link IProjectFragment} to be renamed.
+ * the {@link IProjectFragment} to be renamed.
* @param newName
- * the package fragment root's new name. <code>null</code> is a
- * valid value indicating that no new name is provided.
+ * the package fragment root's new name.
+ * <code>null</code> is a valid value indicating that no
+ * new name is provided.
* @return the {@link RenameSupport}.
* @throws CoreException
- * if an unexpected error occurred while creating the
- * {@link RenameSupport}.
+ * if an unexpected error occurred while creating
+ * the {@link RenameSupport}.
*/
public static RenameSupport create(IProjectFragment root, String newName)
throws CoreException {
@@ -101,19 +103,20 @@ public class RenameSupport {
* Creates a new rename support for the given {@link IScriptFolder}.
*
* @param fragment
- * the {@link IScriptFolder} to be renamed.
+ * the {@link IScriptFolder} to be renamed.
* @param newName
- * the package fragment's new name. <code>null</code> is a valid
- * value indicating that no new name is provided.
+ * the package fragment's new name. <code>null</code> is
+ * a valid value indicating that no new name is
+ * provided.
* @param flags
- * flags controlling additional parameters. Valid flags are
- * <code>UPDATE_REFERENCES</code>, and
- * <code>UPDATE_TEXTUAL_MATCHES</code>, or their bitwise OR, or
- * <code>NONE</code>.
+ * flags controlling additional parameters. Valid flags
+ * are <code>UPDATE_REFERENCES</code>, and
+ * <code>UPDATE_TEXTUAL_MATCHES</code>, or their bitwise
+ * OR, or <code>NONE</code>.
* @return the {@link RenameSupport}.
* @throws CoreException
- * if an unexpected error occurred while creating the
- * {@link RenameSupport}.
+ * if an unexpected error occurred while creating
+ * the {@link RenameSupport}.
*/
public static RenameSupport create(IScriptFolder fragment, String newName,
int flags) throws CoreException {
@@ -126,19 +129,19 @@ public class RenameSupport {
* Creates a new rename support for the given {@link ISourceModule}.
*
* @param unit
- * the {@link ISourceModule} to be renamed.
+ * the {@link ISourceModule} to be renamed.
* @param newName
- * the compilation unit's new name. <code>null</code> is a valid
- * value indicating that no new name is provided.
+ * the compilation unit's new name. <code>null</code> is
+ * a valid value indicating that no new name is provided.
* @param flags
- * flags controlling additional parameters. Valid flags are
- * <code>UPDATE_REFERENCES</code>, and
- * <code>UPDATE_TEXTUAL_MATCHES</code>, or their bitwise OR, or
- * <code>NONE</code>.
+ * flags controlling additional parameters. Valid flags
+ * are <code>UPDATE_REFERENCES</code>, and
+ * <code>UPDATE_TEXTUAL_MATCHES</code>, or their bitwise
+ * OR, or <code>NONE</code>.
* @return the {@link RenameSupport}.
* @throws CoreException
- * if an unexpected error occurred while creating the
- * {@link RenameSupport}.
+ * if an unexpected error occurred while creating
+ * the {@link RenameSupport}.
*/
public static RenameSupport create(ISourceModule unit, String newName,
int flags) throws CoreException {
@@ -166,20 +169,20 @@ public class RenameSupport {
* @return the result of the light weight precondition checking.
*
* @throws CoreException
- * if an unexpected exception occurs while performing the
- * checking.
+ * if an unexpected exception occurs while
+ * performing the checking.
*
* @see #openDialog(Shell)
* @see #perform(Shell, IRunnableContext)
*/
public IStatus preCheck() throws CoreException {
ensureChecked();
- if (fPreCheckStatus.hasFatalError())
+ if (fPreCheckStatus.hasFatalError()) {
return fPreCheckStatus
.getEntryMatchingSeverity(RefactoringStatus.FATAL)
.toStatus();
- else
- return new Status(IStatus.OK, DLTKUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ }
+ return new Status(IStatus.OK, DLTKUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
}
private void ensureChecked() throws CoreException {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/templates/ScriptTemplateCompletionProcessor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/templates/ScriptTemplateCompletionProcessor.java
index 4fc3467b3..f7f39a8f7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/templates/ScriptTemplateCompletionProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/templates/ScriptTemplateCompletionProcessor.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.ui.templates;
@@ -159,7 +158,7 @@ public abstract class ScriptTemplateCompletionProcessor
* characters except the new line characters are selected.
*
* @param viewer
- * the text viewer
+ * the text viewer
* @return <code>true</code> if one or multiple lines are selected
* @since 2.1
*/
@@ -296,9 +295,8 @@ public abstract class ScriptTemplateCompletionProcessor
final int spaceIndex = s.lastIndexOf(' ');
if (spaceIndex != -1) {
return s.substring(spaceIndex);
- } else {
- return s;
}
+ return s;
}
/**
@@ -306,7 +304,7 @@ public abstract class ScriptTemplateCompletionProcessor
* zero.
*
* @param template
- * the template to compute the relevance for
+ * the template to compute the relevance for
* @return the relevance of <code>template</code>
*/
protected int getRelevance(Template template) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/HTMLUtils.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/HTMLUtils.java
index bd194dcbf..bd830a741 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/HTMLUtils.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/HTMLUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 xored software, Inc. and others.
+ * Copyright (c) 2008, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -26,10 +26,10 @@ public class HTMLUtils {
if (display != null && !display.isDisposed()) {
try {
display.asyncExec(() -> {
- BG_COLOR_RGB = display.getSystemColor(
- SWT.COLOR_INFO_BACKGROUND).getRGB();
- FG_COLOR_RGB = display.getSystemColor(
- SWT.COLOR_INFO_FOREGROUND).getRGB();
+ BG_COLOR_RGB = display
+ .getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+ FG_COLOR_RGB = display
+ .getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB();
});
} catch (SWTError err) {
// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=45294
@@ -42,10 +42,9 @@ public class HTMLUtils {
public static RGB getBgColor() {
if (BG_COLOR_RGB != null) {
return BG_COLOR_RGB;
- } else {
- // RGB value of info bg color on WindowsXP
- return new RGB(255, 255, 225);
}
+ // RGB value of info bg color on WindowsXP
+ return new RGB(255, 255, 225);
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCommentScanner.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCommentScanner.java
index 06f72c14c..3f5af8977 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCommentScanner.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCommentScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 xored software, Inc. and others.
+ * Copyright (c) 2008, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -131,7 +131,8 @@ public class ScriptCommentScanner extends AbstractScriptScanner {
* Enables/disables the case-sensitivity of the task tag detection.
*
* @param caseSensitive
- * <code>true</code> iff case-sensitivity should be enabled
+ * <code>true</code> iff case-sensitivity
+ * should be enabled
* @since 3.0
*/
public void setCaseSensitive(boolean caseSensitive) {
@@ -311,10 +312,9 @@ public class ScriptCommentScanner extends AbstractScriptScanner {
protected int skipCommentChars() {
if (read() == getCommentChar()) {
return 1;
- } else {
- unread();
- return 0;
}
+ unread();
+ return 0;
}
/*
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionAssistant.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionAssistant.java
index d9478418f..160c1250b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionAssistant.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionAssistant.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
@@ -51,7 +51,7 @@ public class ScriptCorrectionAssistant extends QuickAssistAssistant {
* Constructor for JavaCorrectionAssistant.
*
* @param editor
- * the editor
+ * the editor
*/
public ScriptCorrectionAssistant(ITextEditor editor, IPreferenceStore store,
IColorManager manager) {
@@ -210,19 +210,18 @@ public class ScriptCorrectionAssistant extends QuickAssistAssistant {
}
}
return bestOffset;
- } else {
- while (iter.hasNext()) {
- Annotation annot = iter.next();
- if (ScriptAnnotationUtils.isQuickFixableType(annot)) {
- Position pos = model.getPosition(annot);
- if (pos != null && isInside(invocationLocation, pos.offset,
- pos.offset + pos.length)) {
- resultingAnnotations.add(annot);
- }
+ }
+ while (iter.hasNext()) {
+ Annotation annot = iter.next();
+ if (ScriptAnnotationUtils.isQuickFixableType(annot)) {
+ Position pos = model.getPosition(annot);
+ if (pos != null && isInside(invocationLocation, pos.offset,
+ pos.offset + pos.length)) {
+ resultingAnnotations.add(annot);
}
}
- return invocationLocation;
}
+ return invocationLocation;
}
private static void ensureUpdatedAnnotations(ITextEditor editor) {
@@ -269,11 +268,11 @@ public class ScriptCorrectionAssistant extends QuickAssistAssistant {
* </p>
*
* @param newOffset
- * the offset to llok at
+ * the offset to llok at
* @param invocationLocation
- * the invocation location
+ * the invocation location
* @param bestOffset
- * the current best offset
+ * the current best offset
* @return -1 is returned if the given offset is not closer or the new best
* offset
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionContext.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionContext.java
index ad5534d19..84483495c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionContext.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptCorrectionContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 xored software, Inc. and others.
+ * Copyright (c) 2008, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -61,9 +61,8 @@ public class ScriptCorrectionContext implements IScriptCorrectionContext {
public ICompletionProposal[] getProposals() {
if (proposals != null) {
return proposals.toArray(new ICompletionProposal[proposals.size()]);
- } else {
- return null;
}
+ return null;
}
private final IQuickAssistInvocationContext invocationContext;
@@ -108,9 +107,8 @@ public class ScriptCorrectionContext implements IScriptCorrectionContext {
public Object getAttribute(String attributeName) {
if (attributes == null) {
return null;
- } else {
- return attributes.get(attributeName);
}
+ return attributes.get(attributeName);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptDefaultIndentLineAutoEditStrategy.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptDefaultIndentLineAutoEditStrategy.java
index 18bc27cd5..77b7e75c0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptDefaultIndentLineAutoEditStrategy.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptDefaultIndentLineAutoEditStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
+ * Copyright (c) 2010, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -19,30 +19,37 @@ import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextUtilities;
-public class ScriptDefaultIndentLineAutoEditStrategy extends DefaultIndentLineAutoEditStrategy {
- protected final IPreferenceStore fPreferenceStore;
+public class ScriptDefaultIndentLineAutoEditStrategy
+ extends DefaultIndentLineAutoEditStrategy {
+ protected final IPreferenceStore fPreferenceStore;
- public ScriptDefaultIndentLineAutoEditStrategy(IPreferenceStore fPreferenceStore) {
- this.fPreferenceStore = fPreferenceStore;
- }
+ public ScriptDefaultIndentLineAutoEditStrategy(
+ IPreferenceStore fPreferenceStore) {
+ this.fPreferenceStore = fPreferenceStore;
+ }
- protected int getIndentSize() {
- return fPreferenceStore.getInt(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
- }
+ protected int getIndentSize() {
+ return fPreferenceStore
+ .getInt(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
+ }
- protected TabStyle getTabStyle() {
- return TabStyle.forName(fPreferenceStore.getString(CodeFormatterConstants.FORMATTER_TAB_CHAR), TabStyle.TAB);
- }
+ protected TabStyle getTabStyle() {
+ return TabStyle.forName(
+ fPreferenceStore
+ .getString(CodeFormatterConstants.FORMATTER_TAB_CHAR),
+ TabStyle.TAB);
+ }
- protected String getIndent() {
- if (getTabStyle() == TabStyle.SPACES) {
- return AutoEditUtils.getNSpaces(getIndentSize());
- } else
- return "\t"; //$NON-NLS-1$
- }
+ protected String getIndent() {
+ if (getTabStyle() == TabStyle.SPACES) {
+ return AutoEditUtils.getNSpaces(getIndentSize());
+ }
+ return "\t"; //$NON-NLS-1$
+ }
- protected boolean isLineDelimiter(IDocument document, String text) {
- String[] delimiters = document.getLegalLineDelimiters();
- return delimiters != null && TextUtilities.equals(delimiters, text) > -1;
- }
+ protected boolean isLineDelimiter(IDocument document, String text) {
+ String[] delimiters = document.getLegalLineDelimiters();
+ return delimiters != null
+ && TextUtilities.equals(delimiters, text) > -1;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptOutlineInformationControl.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptOutlineInformationControl.java
index da277b13c..fd2e99f19 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptOutlineInformationControl.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/ScriptOutlineInformationControl.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
@@ -235,7 +235,8 @@ public class ScriptOutlineInformationControl
* Creates a new Outline content provider.
*
* @param showInheritedMembers
- * <code>true</code> iff inherited members are shown
+ * <code>true</code> iff inherited
+ * members are shown
*/
private OutlineContentProvider(boolean showInheritedMembers) {
super(true);
@@ -370,7 +371,7 @@ public class ScriptOutlineInformationControl
* Creates the action.
*
* @param outlineViewer
- * the outline viewer
+ * the outline viewer
*/
private SortByDefiningTypeAction(TreeViewer outlineViewer) {
super(TextMessages.ScriptOutlineInformationControl_SortByDefiningTypeAction_label);
@@ -540,14 +541,14 @@ public class ScriptOutlineInformationControl
String keySequence = sequences[0].format();
- if (fOutlineContentProvider.isShowingInheritedMembers())
+ if (fOutlineContentProvider.isShowingInheritedMembers()) {
return Messages.format(
TextMessages.ScriptOutlineInformationControl_pressToHideInheritedMembers,
keySequence);
- else
- return Messages.format(
- TextMessages.ScriptOutlineInformationControl_pressToShowInheritedMembers,
- keySequence);
+ }
+ return Messages.format(
+ TextMessages.ScriptOutlineInformationControl_pressToShowInheritedMembers,
+ keySequence);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/AbstractScriptCompletionProposal.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/AbstractScriptCompletionProposal.java
index a527364c4..93e0ec609 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/AbstractScriptCompletionProposal.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/AbstractScriptCompletionProposal.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
@@ -83,8 +83,8 @@ import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
import org.osgi.framework.Bundle;
@SuppressWarnings("restriction")
-public abstract class AbstractScriptCompletionProposal implements
- IScriptCompletionProposal, ICompletionProposalExtension,
+public abstract class AbstractScriptCompletionProposal
+ implements IScriptCompletionProposal, ICompletionProposalExtension,
ICompletionProposalExtension2, ICompletionProposalExtension3,
ICompletionProposalExtension5, ICompletionProposalExtension6,
ICompletionProposalExtension7 {
@@ -107,7 +107,8 @@ public abstract class AbstractScriptCompletionProposal implements
* to postReplace().
*
* @param document
- * the document on which to track the reference position.
+ * the document on which to track the reference
+ * position.
*
*/
public void preReplace(IDocument document, int offset)
@@ -129,7 +130,8 @@ public abstract class AbstractScriptCompletionProposal implements
* call to preReplace().
*
* @param document
- * the document on which to track the reference position.
+ * the document on which to track the reference
+ * position.
*/
public int postReplace(IDocument document) {
try {
@@ -160,11 +162,11 @@ public abstract class AbstractScriptCompletionProposal implements
int offset, int length) {
if (event.character == fExitCharacter) {
- if (environment.anyPositionContains(offset))
+ if (environment.anyPositionContains(offset)) {
return new ExitFlags(ILinkedModeListener.UPDATE_CARET,
false);
- else
- return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
+ }
+ return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
}
switch (event.character) {
@@ -230,8 +232,8 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the trigger characters.
*
* @param triggerCharacters
- * The set of characters which can trigger the application of
- * this completion proposal
+ * The set of characters which can trigger the
+ * application of this completion proposal
*/
public void setTriggerCharacters(char[] triggerCharacters) {
fTriggerCharacters = triggerCharacters;
@@ -241,8 +243,8 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the proposal info.
*
* @param proposalInfo
- * The additional information associated with this proposal or
- * <code>null</code>
+ * The additional information associated with this
+ * proposal or <code>null</code>
*/
public void setProposalInfo(ICompletionProposalInfo proposalInfo) {
fProposalInfo = proposalInfo;
@@ -264,7 +266,7 @@ public abstract class AbstractScriptCompletionProposal implements
* completion)
*
* @param cursorPosition
- * The cursorPosition to set
+ * The cursorPosition to set
*/
public void setCursorPosition(int cursorPosition) {
Assert.isTrue(cursorPosition >= 0);
@@ -278,8 +280,8 @@ public abstract class AbstractScriptCompletionProposal implements
@Override
public final void apply(IDocument document) {
// not used any longer
- apply(document, (char) 0, getReplacementOffset()
- + getReplacementLength());
+ apply(document, (char) 0,
+ getReplacementOffset() + getReplacementLength());
}
@Override
@@ -434,7 +436,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the javadoc attribute.
*
* @param isInDoc
- * <code>true</code> if the proposal is within javadoc
+ * <code>true</code> if the proposal is within javadoc
*/
protected void setInDoc(boolean isInDoc) {
fIsInDoc = isInDoc;
@@ -454,7 +456,8 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the context information.
*
* @param contextInformation
- * The context information associated with this proposal
+ * The context information associated with
+ * this proposal
*/
public void setContextInformation(IContextInformation contextInformation) {
fContextInformation = contextInformation;
@@ -562,7 +565,8 @@ public abstract class AbstractScriptCompletionProposal implements
@Override
public String getAdditionalProposalInfo() {
- final Object info = getAdditionalProposalInfo(new NullProgressMonitor());
+ final Object info = getAdditionalProposalInfo(
+ new NullProgressMonitor());
return info != null ? info.toString() : null;
}
@@ -638,7 +642,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the replacement offset.
*
* @param replacementOffset
- * The replacement offset to set
+ * The replacement offset to set
*/
public void setReplacementOffset(int replacementOffset) {
Assert.isTrue(replacementOffset >= 0);
@@ -646,7 +650,8 @@ public abstract class AbstractScriptCompletionProposal implements
}
@Override
- public int getPrefixCompletionStart(IDocument document, int completionOffset) {
+ public int getPrefixCompletionStart(IDocument document,
+ int completionOffset) {
return getReplacementOffset();
}
@@ -663,7 +668,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the replacement length.
*
* @param replacementLength
- * The replacementLength to set
+ * The replacementLength to set
*/
public void setReplacementLength(int replacementLength) {
Assert.isTrue(replacementLength >= 0);
@@ -683,7 +688,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the replacement string.
*
* @param replacementString
- * The replacement string to set
+ * The replacement string to set
*/
public void setReplacementString(String replacementString) {
Assert.isNotNull(replacementString);
@@ -709,7 +714,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the image.
*
* @param image
- * The image to set
+ * The image to set
*/
public void setImage(Image image) {
fImage = image;
@@ -721,7 +726,8 @@ public abstract class AbstractScriptCompletionProposal implements
}
@Override
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
+ public boolean validate(IDocument document, int offset,
+ DocumentEvent event) {
if (offset < getReplacementOffset())
return false;
@@ -753,7 +759,7 @@ public abstract class AbstractScriptCompletionProposal implements
* </p>
*
* @param prefix
- * the current prefix in the document
+ * the current prefix in the document
* @return <code>true</code> if <code>prefix</code> is a valid prefix of
* this proposal
*/
@@ -782,7 +788,7 @@ public abstract class AbstractScriptCompletionProposal implements
* Sets the proposal's relevance.
*
* @param relevance
- * The relevance to set
+ * The relevance to set
*/
public void setRelevance(int relevance) {
fRelevance = relevance;
@@ -829,14 +835,15 @@ public abstract class AbstractScriptCompletionProposal implements
* <ul>
* <li>getCamelCompound("NuPo", "NullPointerException") ->
* "NuPointerException"</li>
- * <li>getCamelCompound("NuPoE", "NullPointerException") -> "NuPoException"</li>
+ * <li>getCamelCompound("NuPoE", "NullPointerException") ->
+ * "NuPoException"</li>
* <li>getCamelCompound("hasCod", "hashCode") -> "hasCode"</li>
* </ul>
*
* @param prefix
- * the prefix to match against
+ * the prefix to match against
* @param string
- * the string to match
+ * the string to match
* @return a compound of prefix and any postfix taken from
* <code>string</code>
*
@@ -876,8 +883,8 @@ public abstract class AbstractScriptCompletionProposal implements
}
protected boolean insertCompletion() {
- return getPreferenceStore().getBoolean(
- PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
+ return getPreferenceStore()
+ .getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
}
protected Color getForegroundColor(StyledText text) {
@@ -914,9 +921,8 @@ public abstract class AbstractScriptCompletionProposal implements
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
- IRegion modelRange = extension
- .widgetRange2ModelRange(new Region(
- fRememberedStyleRange.start,
+ IRegion modelRange = extension.widgetRange2ModelRange(
+ new Region(fRememberedStyleRange.start,
fRememberedStyleRange.length));
if (modelRange != null)
viewer2.invalidateTextPresentation(
@@ -1046,9 +1052,9 @@ public abstract class AbstractScriptCompletionProposal implements
* typed and an exit position at <code>getCursorPosition() + 1</code>.
*
* @param document
- * the document
+ * the document
* @param closingCharacter
- * the exit character
+ * the exit character
*/
protected void setUpLinkedMode(IDocument document, char closingCharacter) {
if (getTextViewer() != null && autocloseBrackets()) {
@@ -1063,7 +1069,8 @@ public abstract class AbstractScriptCompletionProposal implements
model.addGroup(group);
model.forceInstall();
- LinkedModeUI ui = new EditorLinkedModeUI(model, getTextViewer());
+ LinkedModeUI ui = new EditorLinkedModeUI(model,
+ getTextViewer());
ui.setSimpleMode(true);
ui.setExitPolicy(new ExitPolicy(closingCharacter, document));
ui.setExitPosition(getTextViewer(), exit, 0, Integer.MAX_VALUE);
@@ -1076,8 +1083,8 @@ public abstract class AbstractScriptCompletionProposal implements
}
protected boolean autocloseBrackets() {
- return getPreferenceStore().getBoolean(
- PreferenceConstants.EDITOR_CLOSE_BRACKETS);
+ return getPreferenceStore()
+ .getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS);
}
protected void setDisplayString(String string) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalComparator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalComparator.java
index 66e953f51..daad284ce 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalComparator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalComparator.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
@@ -22,8 +22,8 @@ import org.eclipse.jface.text.templates.TemplateProposal;
* </p>
*
*/
-public final class CompletionProposalComparator implements
- Comparator<ICompletionProposal> {
+public final class CompletionProposalComparator
+ implements Comparator<ICompletionProposal> {
private boolean fOrderAlphabetically;
@@ -39,8 +39,8 @@ public final class CompletionProposalComparator implements
* relevance.
*
* @param orderAlphabetically
- * <code>true</code> to order alphabetically, <code>false</code>
- * to order by relevance
+ * <code>true</code> to order alphabetically,
+ * <code>false</code> to order by relevance
*/
public void setOrderAlphabetically(boolean orderAlphabetically) {
fOrderAlphabetically = orderAlphabetically;
@@ -109,9 +109,8 @@ public final class CompletionProposalComparator implements
private String getSubSortKey(ICompletionProposal obj) {
if (obj instanceof TemplateProposal) {
return ((TemplateProposal) obj).getDisplayString();
- } else {
- return "";
}
+ return "";
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalLabelProviderRegistry.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalLabelProviderRegistry.java
index 594fea235..63b4223a9 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalLabelProviderRegistry.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/CompletionProposalLabelProviderRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
+ * Copyright (c) 2010, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -29,8 +29,7 @@ public class CompletionProposalLabelProviderRegistry {
Object[] instances = manager.getInstances(natureId);
if (instances != null && instances.length != 0) {
return (CompletionProposalLabelProvider) instances[0];
- } else {
- return new CompletionProposalLabelProvider();
}
+ return new CompletionProposalLabelProvider();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/LazyScriptCompletionProposal.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/LazyScriptCompletionProposal.java
index f626c34d5..52a10a77d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/LazyScriptCompletionProposal.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/LazyScriptCompletionProposal.java
@@ -1,13 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.ui.text.completion;
import org.eclipse.core.runtime.Assert;
@@ -20,8 +18,8 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
-public abstract class LazyScriptCompletionProposal extends
- AbstractScriptCompletionProposal {
+public abstract class LazyScriptCompletionProposal
+ extends AbstractScriptCompletionProposal {
protected static final String LPAREN = "("; //$NON-NLS-1$
protected static final String RPAREN = ")"; //$NON-NLS-1$
@@ -77,10 +75,10 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the trigger characters.
- *
+ *
* @param triggerCharacters
- * The set of characters which can trigger the application of
- * this completion proposal
+ * The set of characters which can trigger the
+ * application of this completion proposal
*/
@Override
public final void setTriggerCharacters(char[] triggerCharacters) {
@@ -90,10 +88,10 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the proposal info.
- *
+ *
* @param proposalInfo
- * The additional information associated with this proposal or
- * <code>null</code>
+ * The additional information associated with this
+ * proposal or <code>null</code>
*/
@Override
public final void setProposalInfo(ICompletionProposalInfo proposalInfo) {
@@ -104,7 +102,7 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Returns the additional proposal info, or <code>null</code> if none
* exists.
- *
+ *
* @return the additional proposal info, or <code>null</code> if none exists
*/
@Override
@@ -124,9 +122,9 @@ public abstract class LazyScriptCompletionProposal extends
* Sets the cursor position relative to the insertion offset. By default
* this is the length of the completion string (Cursor positioned after the
* completion)
- *
+ *
* @param cursorPosition
- * The cursorPosition to set
+ * The cursorPosition to set
*/
@Override
public final void setCursorPosition(int cursorPosition) {
@@ -168,9 +166,10 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the context information.
- *
+ *
* @param contextInformation
- * The context information associated with this proposal
+ * The context information associated with
+ * this proposal
*/
@Override
public final void setContextInformation(
@@ -220,11 +219,11 @@ public abstract class LazyScriptCompletionProposal extends
protected StyledString computeStyledDisplayString() {
CompletionProposalLabelProvider labelProvider = fInvocationContext
.getLabelProvider();
- if (labelProvider instanceof ICompletionProposalLabelProviderExtension)
+ if (labelProvider instanceof ICompletionProposalLabelProviderExtension) {
return ((ICompletionProposalLabelProviderExtension) labelProvider)
.createStyledLabel(fProposal);
- else
- return new StyledString(labelProvider.createLabel(fProposal));
+ }
+ return new StyledString(labelProvider.createLabel(fProposal));
}
@Override
@@ -242,7 +241,7 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Gets the replacement offset.
- *
+ *
* @return Returns a int
*/
@Override
@@ -255,9 +254,9 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the replacement offset.
- *
+ *
* @param replacementOffset
- * The replacement offset to set
+ * The replacement offset to set
*/
@Override
public final void setReplacementOffset(int replacementOffset) {
@@ -273,22 +272,22 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Gets the replacement length.
- *
+ *
* @return Returns a int
*/
@Override
public final int getReplacementLength() {
if (!fReplacementLengthComputed)
- setReplacementLength(fProposal.getReplaceEnd()
- - fProposal.getReplaceStart());
+ setReplacementLength(
+ fProposal.getReplaceEnd() - fProposal.getReplaceStart());
return super.getReplacementLength();
}
/**
* Sets the replacement length.
- *
+ *
* @param replacementLength
- * The replacementLength to set
+ * The replacementLength to set
*/
@Override
public final void setReplacementLength(int replacementLength) {
@@ -298,7 +297,7 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Gets the replacement string.
- *
+ *
* @return Returns a String
*/
@Override
@@ -314,9 +313,9 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the replacement string.
- *
+ *
* @param replacementString
- * The replacement string to set
+ * The replacement string to set
*/
@Override
public final void setReplacementString(String replacementString) {
@@ -332,16 +331,15 @@ public abstract class LazyScriptCompletionProposal extends
}
protected Image computeImage() {
- return DLTKUIPlugin.getImageDescriptorRegistry().get(
- fInvocationContext.getLabelProvider().createImageDescriptor(
- fProposal));
+ return DLTKUIPlugin.getImageDescriptorRegistry().get(fInvocationContext
+ .getLabelProvider().createImageDescriptor(fProposal));
}
/**
* Sets the image.
- *
+ *
* @param image
- * The image to set
+ * The image to set
*/
@Override
public final void setImage(Image image) {
@@ -367,7 +365,7 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Gets the proposal's relevance.
- *
+ *
* @return Returns a int
*/
@Override
@@ -379,9 +377,9 @@ public abstract class LazyScriptCompletionProposal extends
/**
* Sets the proposal's relevance.
- *
+ *
* @param relevance
- * The relevance to set
+ * The relevance to set
*/
@Override
public final void setRelevance(int relevance) {
@@ -391,7 +389,7 @@ public abstract class LazyScriptCompletionProposal extends
/**
* TODO (alex) avoid duplicated code.
- *
+ *
* @see ScriptCompletionProposalCollector#computeRelevance(CompletionProposal)
*/
protected int computeRelevance() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposal.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposal.java
index 4ebddef3d..eabdbe0a1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposal.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposal.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 20018 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.ui.text.completion;
@@ -15,25 +14,25 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
-public class ScriptCompletionProposal extends
- AbstractScriptCompletionProposal {
+public class ScriptCompletionProposal extends AbstractScriptCompletionProposal {
/**
* Creates a new completion proposal. All fields are initialized based on
* the provided information.
- *
+ *
* @param replacementString
- * the actual string to be inserted into the document
+ * the actual string to be inserted into the
+ * document
* @param replacementOffset
- * the offset of the text to be replaced
+ * the offset of the text to be replaced
* @param replacementLength
- * the length of the text to be replaced
+ * the length of the text to be replaced
* @param image
- * the image to display for this proposal
+ * the image to display for this proposal
* @param displayString
- * the string to be displayed for the proposal If set to
- * <code>null</code>, the replacement string will be taken as
- * display string.
+ * the string to be displayed for the proposal
+ * If set to <code>null</code>, the replacement
+ * string will be taken as display string.
*/
public ScriptCompletionProposal(String replacementString,
int replacementOffset, int replacementLength, Image image,
@@ -45,24 +44,25 @@ public class ScriptCompletionProposal extends
/**
* Creates a new completion proposal. All fields are initialized based on
* the provided information.
- *
+ *
* @param replacementString
- * the actual string to be inserted into the document
+ * the actual string to be inserted into the
+ * document
* @param replacementOffset
- * the offset of the text to be replaced
+ * the offset of the text to be replaced
* @param replacementLength
- * the length of the text to be replaced
+ * the length of the text to be replaced
* @param image
- * the image to display for this proposal
+ * the image to display for this proposal
* @param displayString
- * the string to be displayed for the proposal If set to
- * <code>null</code>, the replacement string will be taken as
- * display string.
+ * the string to be displayed for the proposal
+ * If set to <code>null</code>, the replacement
+ * string will be taken as display string.
* @param relevance
- * the relevance
+ * the relevance
* @param indoc
- * <code>true</code> for a javadoc proposal
- *
+ * <code>true</code> for a javadoc proposal
+ *
*/
public ScriptCompletionProposal(String replacementString,
int replacementOffset, int replacementLength, Image image,
@@ -74,25 +74,27 @@ public class ScriptCompletionProposal extends
/**
* Creates a new completion proposal. All fields are initialized based on
* the provided information.
- *
+ *
* @param replacementString
- * the actual string to be inserted into the document
+ * the actual string to be inserted into the
+ * document
* @param replacementOffset
- * the offset of the text to be replaced
+ * the offset of the text to be replaced
* @param replacementLength
- * the length of the text to be replaced
+ * the length of the text to be replaced
* @param image
- * the image to display for this proposal
+ * the image to display for this proposal
* @param displayString
- * the StyledString to be displayed for the proposal If set to
- * <code>null</code>, the replacement string will be taken as
- * display string.
+ * the StyledString to be displayed for the
+ * proposal If set to <code>null</code>, the
+ * replacement string will be taken as display
+ * string.
* @param relevance
- * the relevance
+ * the relevance
* @param indoc
- * <code>true</code> for a javadoc proposal
+ * <code>true</code> for a javadoc proposal
* @since 5.2
- *
+ *
*/
public ScriptCompletionProposal(String replacementString,
int replacementOffset, int replacementLength, Image image,
@@ -105,14 +107,14 @@ public class ScriptCompletionProposal extends
setReplacementOffset(replacementOffset);
setReplacementLength(replacementLength);
setImage(image);
- setStyledDisplayString(displayString == null ? new StyledString(
- replacementString)
- : displayString);
+ setStyledDisplayString(
+ displayString == null ? new StyledString(replacementString)
+ : displayString);
setRelevance(relevance);
setCursorPosition(replacementString.length());
setInDoc(indoc);
- setSortString(displayString == null ? replacementString : displayString
- .toString());
+ setSortString(displayString == null ? replacementString
+ : displayString.toString());
}
@Override
@@ -137,10 +139,10 @@ public class ScriptCompletionProposal extends
int completionOffset) {
String string = getReplacementString();
int pos = string.indexOf('(');
- if (pos > 0)
+ if (pos > 0) {
return string.subSequence(0, pos);
- else
- return string;
+ }
+ return string;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposalComputer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposalComputer.java
index 01bd957c9..c8790e032 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposalComputer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptCompletionProposalComputer.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
@@ -75,11 +75,11 @@ public abstract class ScriptCompletionProposalComputer
@Override
public boolean equals(Object object) {
- if (object instanceof ContextInformationWrapper)
+ if (object instanceof ContextInformationWrapper) {
return fContextInformation.equals(
((ContextInformationWrapper) object).fContextInformation);
- else
- return fContextInformation.equals(object);
+ }
+ return fContextInformation.equals(object);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptContentAssistInvocationContext.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptContentAssistInvocationContext.java
index 7f6881a9b..46ae921c6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptContentAssistInvocationContext.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ScriptContentAssistInvocationContext.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 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
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.ui.text.completion;
@@ -25,8 +24,8 @@ import org.eclipse.ui.IEditorPart;
/**
* Describes the context of a content assist invocation in a Script editor.
*/
-public class ScriptContentAssistInvocationContext extends
- ContentAssistInvocationContext {
+public class ScriptContentAssistInvocationContext
+ extends ContentAssistInvocationContext {
private final IEditorPart fEditor;
private ISourceModule fSourceModule = null;
@@ -42,13 +41,13 @@ public class ScriptContentAssistInvocationContext extends
/**
* Creates a new context.
- *
+ *
* @param viewer
- * the viewer used by the editor
+ * the viewer used by the editor
* @param offset
- * the invocation offset
+ * the invocation offset
* @param editor
- * the editor that content assist is invoked in
+ * the editor that content assist is invoked in
*/
public ScriptContentAssistInvocationContext(ITextViewer viewer, int offset,
IEditorPart editor, String natureId) {
@@ -60,9 +59,9 @@ public class ScriptContentAssistInvocationContext extends
/**
* Creates a new context.
- *
+ *
* @param unit
- * the compilation unit in <code>document</code>
+ * the compilation unit in <code>document</code>
*/
public ScriptContentAssistInvocationContext(ISourceModule unit,
String natureId) {
@@ -84,7 +83,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the compilation unit that content assist is invoked in,
* <code>null</code> if there is none.
- *
+ *
* @return the compilation unit that content assist is invoked in, possibly
* <code>null</code>
*/
@@ -94,8 +93,8 @@ public class ScriptContentAssistInvocationContext extends
if (fCollector != null)
fSourceModule = fCollector.getSourceModule();
else {
- IModelElement je = EditorUtility.getEditorInputModelElement(
- fEditor, false);
+ IModelElement je = EditorUtility
+ .getEditorInputModelElement(fEditor, false);
if (je instanceof ISourceModule)
fSourceModule = (ISourceModule) je;
}
@@ -106,7 +105,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the project of the compilation unit that content assist is
* invoked in, <code>null</code> if none.
- *
+ *
* @return the currentscriptproject, possibly <code>null</code>
*/
public IScriptProject getProject() {
@@ -117,7 +116,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the keyword proposals that are available in this context,
* possibly none.
- *
+ *
* @return the available keyword proposals.
*/
public IScriptCompletionProposal[] getKeywordProposals() {
@@ -129,9 +128,9 @@ public class ScriptContentAssistInvocationContext extends
/**
* Sets the collector, which is used to access the compilation unit, the
* core context and the label provider.
- *
+ *
* @param collector
- * the collector
+ * the collector
*/
public void setCollector(ScriptCompletionProposalCollector collector) {
fCollector = collector;
@@ -140,7 +139,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the {@link CompletionContext core completion context} if
* available, <code>null</code> otherwise.
- *
+ *
* @return the core completion context if available, <code>null</code>
* otherwise
*/
@@ -156,9 +155,9 @@ public class ScriptContentAssistInvocationContext extends
* context. 0 signals that the <code>qualifiedTypeName</code> does not match
* the expected type, while 1.0 signals that <code>qualifiedTypeName</code>
* has most recently been used in a similar context.
- *
+ *
* @param qualifiedTypeName
- * the type name of the type of interest
+ * the type name of the type of interest
* @return a relevance in [0.0,&nbsp;1.0] based on previous content assist
* invocations
*/
@@ -168,7 +167,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the content assist type history for the expected type.
- *
+ *
* @return the content assist type history for the expected type
*/
private RHSHistory getRHSHistory() {
@@ -193,7 +192,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns the expected type if any, <code>null</code> otherwise.
- *
+ *
* @return the expected type if any, <code>null</code> otherwise
*/
public IType getExpectedType() {
@@ -220,7 +219,7 @@ public class ScriptContentAssistInvocationContext extends
/**
* Returns a label provider that can be used to compute proposal labels.
- *
+ *
* @return a label provider that can be used to compute proposal labels
*/
public CompletionProposalLabelProvider getLabelProvider() {
@@ -240,9 +239,8 @@ public class ScriptContentAssistInvocationContext extends
public Image getImage(ImageDescriptor descriptor) {
if (fCollector != null) {
return fCollector.getImage(descriptor);
- } else {
- return DLTKUIPlugin.getImageDescriptorRegistry().get(descriptor);
}
+ return DLTKUIPlugin.getImageDescriptorRegistry().get(descriptor);
}
protected final CompletionProposalLabelProvider createLabelProvider() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/AbstractASTFoldingStructureProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/AbstractASTFoldingStructureProvider.java
index 8ba4cf4f5..63f4e3b4a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/AbstractASTFoldingStructureProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/AbstractASTFoldingStructureProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -137,9 +137,9 @@ public abstract class AbstractASTFoldingStructureProvider implements
* the editor.
*
* @param annotation
- * the annotation to add
+ * the annotation to add
* @param position
- * the corresponding position
+ * the corresponding position
*/
public void addProjectionRange(ScriptProjectionAnnotation annotation,
Position position) {
@@ -164,7 +164,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
/**
* @param hash
- * the hash to set
+ * the hash to set
*/
public void setHash(int hash) {
this.hash = hash;
@@ -179,7 +179,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
/**
* @param length
- * the length to set
+ * the length to set
*/
public void setLength(int length) {
this.length = length;
@@ -223,13 +223,15 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Creates a new projection annotation.
*
* @param isCollapsed
- * <code>true</code> to set the initial state to collapsed,
- * <code>false</code> to set it to expanded
+ * <code>true</code> to set the initial state to
+ * collapsed, <code>false</code> to set it to
+ * expanded
* @param codeStamp
- * the stamp of source code this annotation refers to
+ * the stamp of source code this annotation
+ * refers to
* @param isComment
- * <code>true</code> for a foldable comment,
- * <code>false</code> for a foldable code element
+ * <code>true</code> for a foldable comment,
+ * <code>false</code> for a foldable code element
*/
public ScriptProjectionAnnotation(boolean isCollapsed,
boolean isComment, SourceRangeStamp codeStamp,
@@ -257,7 +259,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
/**
* @param stamp
- * the stamp to set
+ * the stamp to set
*/
void setStamp(SourceRangeStamp stamp) {
this.stamp = stamp;
@@ -377,7 +379,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* <code>content</code>. Returns 0 if none is found.
*
* @param content
- * the content to search
+ * the content to search
* @return the first index of a unicode identifier part, or zero if none
* can be found
*/
@@ -477,7 +479,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Registers the listener with the viewer.
*
* @param viewer
- * the viewer to register a listener with
+ * the viewer to register a listener with
*/
public ProjectionListener(ProjectionViewer viewer) {
fViewer = viewer;
@@ -593,9 +595,9 @@ public abstract class AbstractASTFoldingStructureProvider implements
* </p>
*
* @param editor
- * {@inheritDoc}
+ * {@inheritDoc}
* @param viewer
- * {@inheritDoc}
+ * {@inheritDoc}
*/
@Override
public void install(ITextEditor editor, ProjectionViewer viewer,
@@ -948,9 +950,9 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Represents foldable statement.
*
* @param s
- * AST statement
+ * AST statement
* @param r
- * <b>Absolute</b> statement position in source file
+ * <b>Absolute</b> statement position in source file
*/
public CodeBlock(ASTNode s, IRegion r) {
this.statement = s;
@@ -1052,9 +1054,8 @@ public abstract class AbstractASTFoldingStructureProvider implements
final int foldMinLines = getMinimalFoldableLinesCount();
if (foldMinLines > 0) {
return line2 - line1 + 1 >= foldMinLines;
- } else {
- return line1 != line2;
}
+ return line1 != line2;
}
/**
@@ -1063,7 +1064,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* aligned} region.
*
* @param aligned
- * an aligned region
+ * an aligned region
* @return a folding position corresponding to <code>aligned</code>
*/
protected final Position createCommentPosition(IRegion aligned) {
@@ -1076,7 +1077,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* aligned} region.
*
* @param aligned
- * an aligned region
+ * an aligned region
*
* @return a folding position corresponding to <code>aligned</code>
*/
@@ -1094,9 +1095,9 @@ public abstract class AbstractASTFoldingStructureProvider implements
* cannot be folded.
*
* @param region
- * the region to align, may be <code>null</code>
+ * the region to align, may be <code>null</code>
* @param ctx
- * the folding context
+ * the folding context
* @return a region equal or greater than <code>region</code> that is
* aligned with line offsets, <code>null</code> if the region is too
* small to be foldable (e.g. covers only one line)
@@ -1178,10 +1179,11 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Collapses or expands all annotations matched by the passed filter.
*
* @param filter
- * the filter to use to select which annotations to collapse
+ * the filter to use to select which annotations to
+ * collapse
* @param expand
- * <code>true</code> to expand the matched annotations,
- * <code>false</code> to collapse them
+ * <code>true</code> to expand the matched annotations,
+ * <code>false</code> to collapse them
*/
private void modifyFiltered(Filter filter, boolean expand) {
if (!isInstalled())
@@ -1412,7 +1414,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Installs a partitioner with <code>document</code>.
*
* @param document
- * the document
+ * the document
*/
private void installDocumentStuff(Document document) {
IDocumentPartitioner partitioner = getDocumentPartitioner();
@@ -1428,7 +1430,7 @@ public abstract class AbstractASTFoldingStructureProvider implements
* Removes partitioner with <code>document</code>.
*
* @param document
- * the document
+ * the document
*/
private void removeDocumentStuff(Document document) {
document.setDocumentPartitioner(getPartition(), null);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/DelegatingFoldingStructureProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/DelegatingFoldingStructureProvider.java
index 4a8cc43a2..6b28983b1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/DelegatingFoldingStructureProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/DelegatingFoldingStructureProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -115,9 +115,9 @@ public class DelegatingFoldingStructureProvider implements
* the editor.
*
* @param annotation
- * the annotation to add
+ * the annotation to add
* @param position
- * the corresponding position
+ * the corresponding position
*/
public void addProjectionRange(ScriptProjectionAnnotation annotation,
Position position) {
@@ -167,12 +167,13 @@ public class DelegatingFoldingStructureProvider implements
* Creates a new projection annotation.
*
* @param isCollapsed
- * <code>true</code> to set the initial state to collapsed,
- * <code>false</code> to set it to expanded
+ * <code>true</code> to set the initial state to
+ * collapsed, <code>false</code> to set it to
+ * expanded
* @param kind
- * foldable element kind
+ * foldable element kind
* @param element
- * foldable element identity
+ * foldable element identity
*/
public ScriptProjectionAnnotation(boolean isCollapsed,
IFoldingBlockKind kind, Object element) {
@@ -311,7 +312,7 @@ public class DelegatingFoldingStructureProvider implements
* <code>content</code>. Returns 0 if none is found.
*
* @param content
- * the content to search
+ * the content to search
* @return the first index of a unicode identifier part, or zero if none
* can be found
*/
@@ -399,7 +400,7 @@ public class DelegatingFoldingStructureProvider implements
* Registers the listener with the viewer.
*
* @param viewer
- * the viewer to register a listener with
+ * the viewer to register a listener with
*/
public ProjectionListener(ProjectionViewer viewer) {
fViewer = viewer;
@@ -493,9 +494,9 @@ public class DelegatingFoldingStructureProvider implements
* </p>
*
* @param editor
- * {@inheritDoc}
+ * {@inheritDoc}
* @param viewer
- * {@inheritDoc}
+ * {@inheritDoc}
*/
@Override
public void install(ITextEditor editor, ProjectionViewer viewer,
@@ -642,9 +643,8 @@ public class DelegatingFoldingStructureProvider implements
if (!locked) {
locked = true;
return true;
- } else {
- return false;
}
+ return false;
}
/**
@@ -819,7 +819,7 @@ public class DelegatingFoldingStructureProvider implements
* aligned} region.
*
* @param aligned
- * an aligned region
+ * an aligned region
* @return a folding position corresponding to <code>aligned</code>
*/
protected static final Position createCommentPosition(IRegion aligned) {
@@ -832,7 +832,7 @@ public class DelegatingFoldingStructureProvider implements
* aligned} region.
*
* @param aligned
- * an aligned region
+ * an aligned region
*
* @return a folding position corresponding to <code>aligned</code>
*/
@@ -850,9 +850,9 @@ public class DelegatingFoldingStructureProvider implements
* cannot be folded.
*
* @param region
- * the region to align, may be <code>null</code>
+ * the region to align, may be <code>null</code>
* @param ctx
- * the folding context
+ * the folding context
* @return a region equal or greater than <code>region</code> that is
* aligned with line offsets, <code>null</code> if the region is too
* small to be foldable (e.g. covers only one line)
@@ -934,10 +934,11 @@ public class DelegatingFoldingStructureProvider implements
* Collapses or expands all annotations matched by the passed filter.
*
* @param filter
- * the filter to use to select which annotations to collapse
+ * the filter to use to select which annotations to
+ * collapse
* @param expand
- * <code>true</code> to expand the matched annotations,
- * <code>false</code> to collapse them
+ * <code>true</code> to expand the matched annotations,
+ * <code>false</code> to collapse them
*/
private void modifyFiltered(Filter filter, boolean expand) {
if (!isInstalled())
@@ -1008,9 +1009,8 @@ public class DelegatingFoldingStructureProvider implements
if (obj instanceof SourceRangeStamp) {
final SourceRangeStamp other = (SourceRangeStamp) obj;
return length == other.length && hashCode == other.hashCode;
- } else {
- return false;
}
+ return false;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/FoldingProviderManager.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/FoldingProviderManager.java
index 1e41ffc16..46a640bdc 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/FoldingProviderManager.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/folding/FoldingProviderManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
+ * Copyright (c) 2010, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -17,7 +17,8 @@ import org.eclipse.dltk.utils.NatureExtensionManager;
public class FoldingProviderManager {
- public static IFoldingStructureProvider getStructureProvider(String natureId) {
+ public static IFoldingStructureProvider getStructureProvider(
+ String natureId) {
final NatureExtensionManager structureProviders = new NatureExtensionManager(
FOLDING_EXT_POINT, IFoldingStructureProvider.class) {
@Override
@@ -28,9 +29,8 @@ public class FoldingProviderManager {
final Object[] instances = structureProviders.getInstances(natureId);
if (instances != null && instances.length != 0) {
return (IFoldingStructureProvider) instances[0];
- } else {
- return null;
}
+ return null;
}
public static IFoldingBlockProvider[] getBlockProviders(String natureId) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/rules/FloatNumberRule.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/rules/FloatNumberRule.java
index df3f499a1..85c807329 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/rules/FloatNumberRule.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/rules/FloatNumberRule.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -43,14 +43,15 @@ public class FloatNumberRule implements IRule {
/**
* @param token
* @param digitSeparators
- * additional digits separator, e.g. "_" for java7 or
- * <code>null</code> if not applicable
+ * additional digits separator, e.g. "_" for
+ * java7 or <code>null</code> if not applicable
* @param integerSuffixes
- * integer number suffixes, e.g. "Ll" for java or
- * <code>null</code> if not applicable
+ * integer number suffixes, e.g. "Ll" for java or
+ * <code>null</code> if not applicable
* @param floatSuffixes
- * floating point number suffixes, e.g. "DdFf" for java or
- * <code>null</code> if not applicable
+ * floating point number suffixes, e.g. "DdFf"
+ * for java or <code>null</code> if not
+ * applicable
*/
public FloatNumberRule(IToken token, String digitSeparators,
String integerSuffixes, String floatSuffixes) {
@@ -92,10 +93,9 @@ public class FloatNumberRule implements IRule {
unread(scanner, readCount);
return Token.UNDEFINED; // not "0x" prefix
}
- } else if (Character.isDigit((char) c)
- || isSeparator(c)
- || (mode == Mode.HEX && (c >= 'A' && c <= 'F' || c >= 'a'
- && c <= 'f'))) {
+ } else if (Character.isDigit((char) c) || isSeparator(c)
+ || (mode == Mode.HEX && (c >= 'A' && c <= 'F'
+ || c >= 'a' && c <= 'f'))) {
digitCount++;
} else if (c == '.' && mode == Mode.DECIMAL) {
mode = Mode.FLOAT;
@@ -126,14 +126,15 @@ public class FloatNumberRule implements IRule {
return Token.UNDEFINED;
}
}
- if (!(((mode == Mode.DECIMAL || mode == Mode.FLOAT) && isFloatSuffix(c)) || (mode == Mode.DECIMAL && isDecimalSuffix(c)))) {
+ if (!(((mode == Mode.DECIMAL || mode == Mode.FLOAT)
+ && isFloatSuffix(c))
+ || (mode == Mode.DECIMAL && isDecimalSuffix(c)))) {
scanner.unread();
}
return fToken;
- } else {
- scanner.unread();
- return Token.UNDEFINED;
}
+ scanner.unread();
+ return Token.UNDEFINED;
}
private final void unread(ICharacterScanner scanner, int count) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/spelling/SpellCheckDelegate.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/spelling/SpellCheckDelegate.java
index 5902336aa..b537f5374 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/spelling/SpellCheckDelegate.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/spelling/SpellCheckDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2017 NumberFour AG and others.
+ * Copyright (c) 2011, 2018 NumberFour AG and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -42,9 +42,8 @@ public class SpellCheckDelegate {
public IRegion[] computeRegions(ITypedRegion partition) {
if (ignoredContentTypes.contains(partition.getType())) {
return null;
- } else {
- return asArray(partition);
}
+ return asArray(partition);
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/templates/ProjectTemplateStore.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/templates/ProjectTemplateStore.java
index ea186be61..9f2642630 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/templates/ProjectTemplateStore.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/templates/ProjectTemplateStore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -110,9 +110,8 @@ public class ProjectTemplateStore {
public TemplatePersistenceData[] getTemplateData() {
if (fProjectStore != null) {
return fProjectStore.getTemplateData(true);
- } else {
- return fInstanceStore.getTemplateData(true);
}
+ return fInstanceStore.getTemplateData(true);
}
public Template findTemplateById(String id) {
@@ -167,9 +166,8 @@ public class ProjectTemplateStore {
TemplatePersistenceData data = fProjectStore.getTemplateData(id);
if (data == null) {
return; // does not exist
- } else {
- data.setDeleted(!projectSpecific);
}
+ data.setDeleted(!projectSpecific);
}
public void restoreDefaults() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ExceptionHandler.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ExceptionHandler.java
index 0c858089e..ccebfa3f6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ExceptionHandler.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ExceptionHandler.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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.ui.util;
@@ -50,13 +49,13 @@ public class ExceptionHandler {
/**
* Handles the given <code>CoreException</code>. The workbench shell is used
* as a parent for the dialog window.
- *
+ *
* @param e
- * the <code>CoreException</code> to be handled
+ * the <code>CoreException</code> to be handled
* @param title
- * the dialog window's window title
+ * the dialog window's window title
* @param message
- * message to be displayed by the dialog window
+ * message to be displayed by the dialog window
*/
public static void handle(CoreException e, String title, String message) {
handle(e, DLTKUIPlugin.getActiveWorkbenchShell(), title, message);
@@ -64,15 +63,15 @@ public class ExceptionHandler {
/**
* Handles the given <code>CoreException</code>.
- *
+ *
* @param e
- * the <code>CoreException</code> to be handled
+ * the <code>CoreException</code> to be handled
* @param parent
- * the dialog window's parent shell
+ * the dialog window's parent shell
* @param title
- * the dialog window's window title
+ * the dialog window's window title
* @param message
- * message to be displayed by the dialog window
+ * message to be displayed by the dialog window
*/
public static void handle(CoreException e, Shell parent, String title,
String message) {
@@ -82,13 +81,14 @@ public class ExceptionHandler {
/**
* Handles the given <code>InvocationTargetException</code>. The workbench
* shell is used as a parent for the dialog window.
- *
+ *
* @param e
- * the <code>InvocationTargetException</code> to be handled
+ * the <code>InvocationTargetException</code> to be
+ * handled
* @param title
- * the dialog window's window title
+ * the dialog window's window title
* @param message
- * message to be displayed by the dialog window
+ * message to be displayed by the dialog window
*/
public static void handle(InvocationTargetException e, String title,
String message) {
@@ -97,15 +97,16 @@ public class ExceptionHandler {
/**
* Handles the given <code>InvocationTargetException</code>.
- *
+ *
* @param e
- * the <code>InvocationTargetException</code> to be handled
+ * the <code>InvocationTargetException</code> to be
+ * handled
* @param parent
- * the dialog window's parent shell
+ * the dialog window's parent shell
* @param title
- * the dialog window's window title
+ * the dialog window's window title
* @param message
- * message to be displayed by the dialog window
+ * message to be displayed by the dialog window
*/
public static void handle(InvocationTargetException e, Shell parent,
String title, String message) {
@@ -147,16 +148,15 @@ public class ExceptionHandler {
final IStatus[] children = status.getChildren();
for (int i = 0; i < children.length; ++i) {
final IStatus child = children[i];
- if (!(ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin()) && child
- .getCode() == IResourceStatus.INVALID_RESOURCE_NAME)) {
+ if (!(ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin())
+ && child.getCode() == IResourceStatus.INVALID_RESOURCE_NAME)) {
return false;
}
}
return true;
- } else {
- if (status.getCode() == IResourceStatus.INVALID_RESOURCE_NAME) {
- return true;
- }
+ }
+ if (status.getCode() == IResourceStatus.INVALID_RESOURCE_NAME) {
+ return true;
}
return false;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ScriptProjectNaturePropertyTester.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ScriptProjectNaturePropertyTester.java
index 4dcef450a..e600b667a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ScriptProjectNaturePropertyTester.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/util/ScriptProjectNaturePropertyTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -31,9 +31,8 @@ public class ScriptProjectNaturePropertyTester extends PropertyTester {
.hasScriptNature((IProject) receiver);
if (expectedValue instanceof Boolean) {
return result == ((Boolean) expectedValue).booleanValue();
- } else {
- return result;
}
+ return result;
}
}
return false;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/ResourceToItemsMapper.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/ResourceToItemsMapper.java
index 33bd7c7fa..a06826274 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/ResourceToItemsMapper.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/ResourceToItemsMapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 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
@@ -20,53 +20,53 @@ import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Widget;
-
/**
- * Helper class for updating error markers and other decorators that work on resources.
- * Items are mapped to their element's underlying resource.
- * Method <code>resourceChanged</code> updates all items that are affected from the changed
- * elements.
+ * Helper class for updating error markers and other decorators that work on
+ * resources. Items are mapped to their element's underlying resource. Method
+ * <code>resourceChanged</code> updates all items that are affected from the
+ * changed elements.
*/
public class ResourceToItemsMapper {
-
+
public static interface IContentViewerAccessor {
public void doUpdateItem(Widget item);
}
-
- private static final int NUMBER_LIST_REUSE= 10;
+ private static final int NUMBER_LIST_REUSE = 10;
// map from resource to item
private HashMap fResourceToItem;
private Stack fReuseLists;
-
+
private IContentViewerAccessor fContentViewerAccess;
public ResourceToItemsMapper(IContentViewerAccessor viewer) {
- fResourceToItem= new HashMap();
- fReuseLists= new Stack();
-
- fContentViewerAccess= viewer;
+ fResourceToItem = new HashMap();
+ fReuseLists = new Stack();
+
+ fContentViewerAccess = viewer;
}
/**
* Must be called from the UI thread.
- * @param changedResource Changed resource
+ *
+ * @param changedResource
+ * Changed resource
*/
public void resourceChanged(IResource changedResource) {
- Object obj= fResourceToItem.get(changedResource);
+ Object obj = fResourceToItem.get(changedResource);
if (obj == null) {
// not mapped
} else if (obj instanceof Item) {
updateItem((Item) obj);
} else { // List of Items
- List list= (List) obj;
- for (int k= 0; k < list.size(); k++) {
+ List list = (List) obj;
+ for (int k = 0; k < list.size(); k++) {
updateItem((Item) list.get(k));
}
}
}
-
+
private void updateItem(Item item) {
if (!item.isDisposed()) {
fContentViewerAccess.doUpdateItem(item);
@@ -75,24 +75,27 @@ public class ResourceToItemsMapper {
/**
* Adds a new item to the map.
- * @param element Element to map
- * @param item The item used for the element
+ *
+ * @param element
+ * Element to map
+ * @param item
+ * The item used for the element
*/
public void addToMap(Object element, Item item) {
- IResource resource= getCorrespondingResource(element);
+ IResource resource = getCorrespondingResource(element);
if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
+ Object existingMapping = fResourceToItem.get(resource);
if (existingMapping == null) {
fResourceToItem.put(resource, item);
} else if (existingMapping instanceof Item) {
if (existingMapping != item) {
- List list= getNewList();
+ List list = getNewList();
list.add(existingMapping);
list.add(item);
fResourceToItem.put(resource, list);
}
- } else { // List
- List list= (List) existingMapping;
+ } else { // List
+ List list = (List) existingMapping;
if (!list.contains(item)) {
list.add(item);
}
@@ -102,19 +105,22 @@ public class ResourceToItemsMapper {
/**
* Removes an element from the map.
- * @param element The data element
- * @param item The table or tree item
- */
+ *
+ * @param element
+ * The data element
+ * @param item
+ * The table or tree item
+ */
public void removeFromMap(Object element, Item item) {
- IResource resource= getCorrespondingResource(element);
+ IResource resource = getCorrespondingResource(element);
if (resource != null) {
- Object existingMapping= fResourceToItem.get(resource);
+ Object existingMapping = fResourceToItem.get(resource);
if (existingMapping == null) {
return;
} else if (existingMapping instanceof Item) {
fResourceToItem.remove(resource);
} else { // List
- List list= (List) existingMapping;
+ List list = (List) existingMapping;
list.remove(item);
if (list.isEmpty()) {
fResourceToItem.remove(list);
@@ -123,34 +129,35 @@ public class ResourceToItemsMapper {
}
}
}
-
+
private List getNewList() {
if (!fReuseLists.isEmpty()) {
return (List) fReuseLists.pop();
}
return new ArrayList(2);
}
-
+
private void releaseList(List list) {
if (fReuseLists.size() < NUMBER_LIST_REUSE) {
fReuseLists.push(list);
}
}
-
+
/**
* Clears the map.
*/
public void clearMap() {
fResourceToItem.clear();
}
-
+
/**
* Tests if the map is empty
+ *
* @return Returns if there are mappings
*/
public boolean isEmpty() {
return fResourceToItem.isEmpty();
- }
+ }
private static IResource getCorrespondingResource(IModelElement elem) {
IResource res = elem.getResource();
@@ -167,29 +174,27 @@ public class ResourceToItemsMapper {
}
/**
- * Method that decides which elements can have error markers
- * Returns null if an element can not have error markers.
- * @param element The input element
+ * Method that decides which elements can have error markers Returns null if
+ * an element can not have error markers.
+ *
+ * @param element
+ * The input element
* @return Returns the corresponding resource or null
- */
+ */
private static IResource getCorrespondingResource(Object element) {
if (element instanceof IModelElement) {
return getCorrespondingResource((IModelElement) element);
} else if (element instanceof IResource) {
return (IResource) element;
} else if (element instanceof IAdaptable) {
- IResource res;
IModelElement elem = ((IAdaptable) element)
.getAdapter(IModelElement.class);
if (elem != null) {
return getCorrespondingResource(elem);
- } else {
- res = (((IAdaptable) element)
- .getAdapter(IResource.class));
}
- return res;
+ return (((IAdaptable) element).getAdapter(IResource.class));
}
return null;
}
-
+
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/StatusBarUpdater.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/StatusBarUpdater.java
index 65c5d708b..0b5471fc4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/StatusBarUpdater.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/viewsupport/StatusBarUpdater.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,23 +60,21 @@ public class StatusBarUpdater implements ISelectionChangedListener {
return Messages.format(
DLTKUIMessages.StatusBarUpdater_num_elements_selected,
String.valueOf(nElements));
- } else {
- Object elem = selection.getFirstElement();
- if (elem instanceof IModelElement) {
- return formatModelElementMessage((IModelElement) elem);
- } else if (elem instanceof IResource) {
- return formatResourceMessage((IResource) elem);
- } else if (elem instanceof BuildPathContainer) {
- BuildPathContainer container = (BuildPathContainer) elem;
- return container.getLabel()
- + ScriptElementLabels.CONCAT_STRING
- + container.getScriptProject().getElementName();
- } else if (elem instanceof IAdaptable) {
- IWorkbenchAdapter wbadapter = ((IAdaptable) elem)
- .getAdapter(IWorkbenchAdapter.class);
- if (wbadapter != null) {
- return wbadapter.getLabel(elem);
- }
+ }
+ Object elem = selection.getFirstElement();
+ if (elem instanceof IModelElement) {
+ return formatModelElementMessage((IModelElement) elem);
+ } else if (elem instanceof IResource) {
+ return formatResourceMessage((IResource) elem);
+ } else if (elem instanceof BuildPathContainer) {
+ BuildPathContainer container = (BuildPathContainer) elem;
+ return container.getLabel() + ScriptElementLabels.CONCAT_STRING
+ + container.getScriptProject().getElementName();
+ } else if (elem instanceof IAdaptable) {
+ IWorkbenchAdapter wbadapter = ((IAdaptable) elem)
+ .getAdapter(IWorkbenchAdapter.class);
+ if (wbadapter != null) {
+ return wbadapter.getLabel(elem);
}
}
}
@@ -90,11 +88,11 @@ public class StatusBarUpdater implements ISelectionChangedListener {
private String formatResourceMessage(IResource element) {
IContainer parent = element.getParent();
- if (parent != null && parent.getType() != IResource.ROOT)
+ if (parent != null && parent.getType() != IResource.ROOT) {
return element.getName() + ScriptElementLabels.CONCAT_STRING
+ parent.getFullPath().makeRelative().toString();
- else
- return element.getName();
+ }
+ return element.getName();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/BuildpathsBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/BuildpathsBlock.java
index 81951f871..ec8f2b8f1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/BuildpathsBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/BuildpathsBlock.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
@@ -103,7 +103,7 @@ public class BuildpathsBlock {
* removed from the old output location.
*
* @param oldOutputLocation
- * The old output location
+ * The old output location
* @return Returns true if .class files should be removed.
* @throws OperationCanceledException
*/
@@ -277,17 +277,20 @@ public class BuildpathsBlock {
* given or default paths.
*
* @param jproject
- * The java project to configure. Does not have to exist.
+ * The java project to configure. Does not have
+ * to exist.
* @param outputLocation
- * The output location to be set in the page. If
- * <code>null</code> is passed, jdt default settings are used, or
- * - if the project is an existing script project- the output
- * location of the existing project
+ * The output location to be set in the page. If
+ * <code>null</code> is passed, jdt default
+ * settings are used, or - if the project is an
+ * existing script project- the output location
+ * of the existing project
* @param buildpathEntries
- * The buildpath entries to be set in the page. If
- * <code>null</code> is passed, jdt default settings are used, or
- * - if the project is an existing script project - the buildpath
- * entries of the existing project
+ * The buildpath entries to be set in the page.
+ * If <code>null</code> is passed, jdt default
+ * settings are used, or - if the project is an
+ * existing script project - the buildpath
+ * entries of the existing project
*/
public void init(IScriptProject jproject,
IBuildpathEntry[] buildpathEntries) {
@@ -428,9 +431,8 @@ public class BuildpathsBlock {
protected IDLTKLanguageToolkit getLanguageToolkit() {
if (fContext instanceof IScriptLanguageProvider) {
return ((IScriptLanguageProvider) fContext).getLanguageToolkit();
- } else {
- return null;
}
+ return null;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewContainerWizardPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewContainerWizardPage.java
index 05812a6ca..20708ffb6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewContainerWizardPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewContainerWizardPage.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
@@ -109,8 +109,8 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
}
}
- private class ContainerFieldAdapter implements IStringButtonAdapter,
- IDialogFieldListener {
+ private class ContainerFieldAdapter
+ implements IStringButtonAdapter, IDialogFieldListener {
@Override
public void changeControlPressed(DialogField field) {
containerChangeControlPressed(field);
@@ -126,7 +126,7 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* Create a new <code>NewContainerWizardPage</code>
*
* @param name
- * the wizard page's name
+ * the wizard page's name
*/
public NewContainerWizardPage(String name) {
super(name);
@@ -135,8 +135,8 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
containerDialogField = new StringButtonDialogField(adapter);
containerDialogField.setDialogFieldListener(adapter);
containerDialogField.setLabelText(getContainerLabel());
- containerDialogField
- .setButtonLabel(NewWizardMessages.NewContainerWizardPage_container_button);
+ containerDialogField.setButtonLabel(
+ NewWizardMessages.NewContainerWizardPage_container_button);
containerStatus = new StatusInfo();
currRoot = null;
}
@@ -156,8 +156,8 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* The package fragment root is computed from the given Script element.
*
* @param elem
- * the Script element used to compute the initial package
- * fragment root used as the source folder
+ * the Script element used to compute the initial package
+ * fragment root used as the source folder
*/
protected void initContainerPage(IModelElement elem) {
IScriptFolder initRoot = null;
@@ -184,16 +184,18 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
IProjectFragment[] roots = project
.getProjectFragments();
for (int i = 0; i < roots.length; i++) {
- if (roots[i].getKind() == IProjectFragment.K_SOURCE) {
+ if (roots[i]
+ .getKind() == IProjectFragment.K_SOURCE) {
initRoot = roots[i].getScriptFolder(""); //$NON-NLS-1$
break;
}
}
}
if (initRoot == null) {
- initRoot = project.getProjectFragment(
- project.getResource()).getScriptFolder(
- ""); //$NON-NLS-1$
+ initRoot = project
+ .getProjectFragment(
+ project.getResource())
+ .getScriptFolder(""); //$NON-NLS-1$
}
}
}
@@ -210,7 +212,7 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* Utility method to inspect a selection to find a Script element.
*
* @param selection
- * the selection to be inspected
+ * the selection to be inspected
* @return a Script element to be used as the initial selection, or
* <code>null</code>, if no Script element exists in the given
* selection
@@ -225,14 +227,12 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
// Check for adapters
if (selectedElement instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) selectedElement;
- scriptElement = adaptable
- .getAdapter(IModelElement.class);
+ scriptElement = adaptable.getAdapter(IModelElement.class);
if (scriptElement != null && scriptElement.isReadOnly()) {
scriptElement = scriptElement.getScriptProject();
}
if (scriptElement == null) {
- IResource resource = adaptable
- .getAdapter(IResource.class);
+ IResource resource = adaptable.getAdapter(IResource.class);
if (resource != null
&& resource.getType() != IResource.ROOT) {
while (scriptElement == null
@@ -266,8 +266,8 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
}
}
- if (scriptElement == null
- || scriptElement.getElementType() == IModelElement.SCRIPT_MODEL) {
+ if (scriptElement == null || scriptElement
+ .getElementType() == IModelElement.SCRIPT_MODEL) {
try {
IScriptProject[] projects = DLTKCore.create(getWorkspaceRoot())
.getScriptProjects();
@@ -301,10 +301,10 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* the grid layout has at least 3 columns.
*
* @param parent
- * the parent composite
+ * the parent composite
* @param nColumns
- * the number of columns to span. This number must be greater or
- * equal three
+ * the number of columns to span. This number must be
+ * greater or equal three
*/
protected void createContainerControls(Composite parent, int nColumns) {
containerDialogField.doFillIntoGrid(parent, nColumns);
@@ -353,8 +353,8 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
currRoot = null;
String str = getScriptFolderText();
if (str.length() == 0) {
- status
- .setError(NewWizardMessages.NewContainerWizardPage_error_EnterContainerName);
+ status.setError(
+ NewWizardMessages.NewContainerWizardPage_error_EnterContainerName);
return status;
}
IPath path = new Path(str);
@@ -364,11 +364,9 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
IProject proj = res.getProject();
if (!proj.isOpen()) {
- status
- .setError(Messages
- .format(
- NewWizardMessages.NewContainerWizardPage_error_ProjectClosed,
- proj.getFullPath().toString()));
+ status.setError(Messages.format(
+ NewWizardMessages.NewContainerWizardPage_error_ProjectClosed,
+ proj.getFullPath().toString()));
return status;
}
@@ -395,9 +393,9 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
}
if (projectFragment != null) {
IPath fragmentPath = projectFragment.getPath();
- currRoot = projectFragment.getScriptFolder(path
- .removeFirstSegments(fragmentPath
- .segmentCount()));
+ currRoot = projectFragment
+ .getScriptFolder(path.removeFirstSegments(
+ fragmentPath.segmentCount()));
}
}
}
@@ -410,38 +408,32 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
String nature = getRequiredNature();
if (nature != null && !proj.hasNature(nature)) {
if (resType == IResource.PROJECT) {
- status
- .setError(NewWizardMessages.NewContainerWizardPage_warning_NotAScriptProject);
+ status.setError(
+ NewWizardMessages.NewContainerWizardPage_warning_NotAScriptProject);
} else {
- status
- .setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotInAScriptProject);
+ status.setWarning(
+ NewWizardMessages.NewContainerWizardPage_warning_NotInAScriptProject);
}
return status;
}
// }
} catch (CoreException e) {
- status
- .setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotAScriptProject);
+ status.setWarning(
+ NewWizardMessages.NewContainerWizardPage_warning_NotAScriptProject);
}
}
return status;
- } else {
- status
- .setError(Messages
- .format(
- NewWizardMessages.NewContainerWizardPage_error_NotAFolder,
- str));
- return status;
}
- } else {
- status
- .setError(Messages
- .format(
- NewWizardMessages.NewContainerWizardPage_error_ContainerDoesNotExist,
- str));
+ status.setError(Messages.format(
+ NewWizardMessages.NewContainerWizardPage_error_NotAFolder,
+ str));
return status;
}
+ status.setError(Messages.format(
+ NewWizardMessages.NewContainerWizardPage_error_ContainerDoesNotExist,
+ str));
+ return status;
}
// -------- update message ----------------
@@ -456,8 +448,9 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* field changes (check for duplicated class names).
*
* @param fieldName
- * The name of the field that has changed (field id). For the
- * source folder the field id is <code>CONTAINER</code>
+ * The name of the field that has changed (field id).
+ * For the source folder the field id is
+ * <code>CONTAINER</code>
*/
protected void handleFieldChanged(String fieldName) {
}
@@ -520,15 +513,16 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* package fragment root.
*
* @param root
- * The new root.
+ * The new root.
* @param canBeModified
- * if <code>false</code> the source folder field can not be
- * changed by the user. If <code>true</code> the field is
- * editable
+ * if <code>false</code> the source folder field
+ * can not be changed by the user. If
+ * <code>true</code> the field is editable
*/
public void setScriptFolder(IScriptFolder root, boolean canBeModified) {
currRoot = root;
- String str = (root == null) ? "" : root.getPath().makeRelative().toString(); //$NON-NLS-1$
+ String str = (root == null) ? "" //$NON-NLS-1$
+ : root.getPath().makeRelative().toString();
containerDialogField.setText(str);
containerDialogField.setEnabled(canBeModified);
}
@@ -560,11 +554,11 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
* filter.
*
* @param initElement
- * initially selected element
+ * initially selected element
* @param filter
- * viewer filter
+ * viewer filter
* @param validator
- * selection validator, may be null
+ * selection validator, may be null
*/
protected IScriptFolder doChooseContainer(IModelElement initElement,
ViewerFilter filter, ISelectionStatusValidator validator) {
@@ -575,8 +569,10 @@ public abstract class NewContainerWizardPage extends NewElementWizardPage {
getShell(), labelProvider, provider);
dialog.setComparator(new ModelElementSorter());
- dialog.setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title);
- dialog.setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description);
+ dialog.setTitle(
+ NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title);
+ dialog.setMessage(
+ NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description);
dialog.addFilter(filter);
if (validator != null) {
dialog.setValidator(validator);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleInPackagePage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleInPackagePage.java
index c2d2a9a0c..c98b1c0a0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleInPackagePage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleInPackagePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 NumberFour AG and others.
+ * Copyright (c) 2012, 2018 NumberFour AG and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -190,9 +190,8 @@ public abstract class NewSourceModuleInPackagePage extends NewSourceModulePage {
if (src != null) {
if (currentPackagePath == null) {
return src.getScriptFolder("");
- } else {
- return src.getScriptFolder(currentPackagePath);
}
+ return src.getScriptFolder(currentPackagePath);
}
return null;
}
@@ -214,10 +213,10 @@ public abstract class NewSourceModuleInPackagePage extends NewSourceModulePage {
* Sets the content of the package input field to the given value.
*
* @param str
- * the new package input field text
+ * the new package input field text
* @param canBeModified
- * if <code>true</code> the package input field can be modified;
- * otherwise it is read-only.
+ * if <code>true</code> the package input field can
+ * be modified; otherwise it is read-only.
*/
public void setPackageText(String str, boolean canBeModified) {
fPackageDialogField.setText(str);
@@ -439,11 +438,11 @@ public abstract class NewSourceModuleInPackagePage extends NewSourceModulePage {
* field changes (check for duplicated class names).
*
* @param fieldName
- * The name of the field that has changed (field id). For the
- * source folder the field id is
- * {@link NewContainerWizardPage#CONTAINER} , for the package
- * it's {@link #PACKAGE}, and for the file name
- * {@link NewSourceModulePage#FILE}
+ * The name of the field that has changed (field id).
+ * For the source folder the field id is
+ * {@link NewContainerWizardPage#CONTAINER} , for the
+ * package it's {@link #PACKAGE}, and for the file name
+ * {@link NewSourceModulePage#FILE}
*/
@Override
protected void handleFieldChanged(String fieldName) {
@@ -484,10 +483,10 @@ public abstract class NewSourceModuleInPackagePage extends NewSourceModulePage {
* layout manager and that the grid layout has at least 3 columns.
*
* @param parent
- * the parent composite
+ * the parent composite
* @param nColumns
- * the number of columns to span. This number must be greater or
- * equal three
+ * the number of columns to span. This number must be
+ * greater or equal three
*/
@Override
protected void createContainerControls(Composite parent, int nColumns) {
@@ -501,9 +500,9 @@ public abstract class NewSourceModuleInPackagePage extends NewSourceModulePage {
* called if packages are supported.
*
* @param composite
- * the parent composite
+ * the parent composite
* @param nColumns
- * number of columns to span
+ * number of columns to span
*/
protected void createPackageControls(Composite composite, int nColumns) {
fPackageDialogField.doFillIntoGrid(composite, nColumns);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleWizard.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleWizard.java
index e290618b3..3808a16e6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/NewSourceModuleWizard.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
@@ -201,9 +201,8 @@ public abstract class NewSourceModuleWizard extends NewElementWizard
public String getMode() {
if (!created) {
return mode;
- } else {
- return page.getMode();
}
+ return page.getMode();
}
/**
@@ -289,7 +288,7 @@ public abstract class NewSourceModuleWizard extends NewElementWizard
.get(field);
if (list != null) {
for (IFieldChangeListener listener : list) {
- if (listener instanceof IFieldChangeListener) {
+ if (listener != null) {
listener.fieldChanged();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectCreator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectCreator.java
index 80b5276bd..e29fe7c1d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectCreator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software Inc. and others.
+ * Copyright (c) 2009, 2018 xored software Inc. 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
@@ -310,8 +310,8 @@ public class ProjectCreator {
*
* @param kind
* @param priority
- * the priority of the specified step. steps with greater
- * priority are executed later
+ * the priority of the specified step. steps with
+ * greater priority are executed later
* @param step
* @param mode
*/
@@ -600,15 +600,16 @@ public class ProjectCreator {
* configured. No natures are added.
*
* @param project
- * The handle of the project to create.
+ * The handle of the project to create.
* @param locationURI
- * The location of the project or <code>null</code> to create the
- * project in the workspace
+ * The location of the project or <code>null</code>
+ * to create the project in the workspace
* @param monitor
- * a progress monitor to report progress or <code>null</code> if
- * progress reporting is not desired
+ * a progress monitor to report progress or
+ * <code>null</code> if progress reporting is not
+ * desired
* @throws CoreException
- * if the project couldn't be created
+ * if the project couldn't be created
* @see org.eclipse.core.resources.IProjectDescription#setLocationURI(java.net.URI)
*/
protected void createProject(IProject project, URI locationURI,
@@ -636,10 +637,9 @@ public class ProjectCreator {
detector.detectBuildpath(
new SubProgressMonitor(monitor, WORK_INIT_BP));
return detector.getBuildpath();
- } else {
- monitor.worked(WORK_INIT_BP);
- return null;
}
+ monitor.worked(WORK_INIT_BP);
+ return null;
} else if (fLocation.isSrc()) {
final IDLTKUILanguageToolkit toolkit = getUILanguageToolkit();
final IPath srcPath = toolkit != null
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectWizardFirstPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectWizardFirstPage.java
index 1dd951590..6dfe4f964 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectWizardFirstPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/ProjectWizardFirstPage.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
@@ -405,9 +405,8 @@ public abstract class ProjectWizardFirstPage extends WizardPage
.get(DIALOGSTORE_LAST_EXTERNAL_ENVIRONMENT);
if (savedEnvId == null || savedEnvId.equals(environment.getId())) {
return ds.get(DIALOGSTORE_LAST_EXTERNAL_LOC);
- } else {
- return null;
}
+ return null;
}
/**
@@ -665,10 +664,10 @@ public abstract class ProjectWizardFirstPage extends WizardPage
IInterpreterInstall inst = ScriptRuntime
.getDefaultInterpreterInstall(getCurrentLanguageNature(),
getEnvironment());
- if (inst != null)
+ if (inst != null) {
return inst.getName();
- else
- return "undefined"; //$NON-NLS-1$
+ }
+ return "undefined"; //$NON-NLS-1$
}
private String getDefaultInterpreterLabel() {
@@ -786,9 +785,8 @@ public abstract class ProjectWizardFirstPage extends WizardPage
public Control getDecorationTarget() {
if (fUseDefaultInterpreter.isSelected()) {
return fUseDefaultInterpreter.getSelectionButton();
- } else {
- return fUseProjectInterpreter.getSelectionButton();
}
+ return fUseProjectInterpreter.getSelectionButton();
}
}
@@ -926,22 +924,19 @@ public abstract class ProjectWizardFirstPage extends WizardPage
if (fLocationGroup.isInWorkspace()) {
if (!isValidProjectName(getProjectName())) {
return false;
- } else {
- final IEnvironment environment = EnvironmentManager
- .getLocalEnvironment();
- final IFileHandle directory = environment
- .getFile(location.append(getProjectName()));
- return directory.isDirectory();
- }
- } else {
- IEnvironment environment = fLocationGroup.getEnvironment();
- if (!location.isEmpty()) {
- final IFileHandle directory = environment.getFile(location);
- return directory.isDirectory();
- } else {
- return false;
}
+ final IEnvironment environment = EnvironmentManager
+ .getLocalEnvironment();
+ final IFileHandle directory = environment
+ .getFile(location.append(getProjectName()));
+ return directory.isDirectory();
+ }
+ IEnvironment environment = fLocationGroup.getEnvironment();
+ if (!location.isEmpty()) {
+ final IFileHandle directory = environment.getFile(location);
+ return directory.isDirectory();
}
+ return false;
}
@Override
@@ -1191,9 +1186,8 @@ public abstract class ProjectWizardFirstPage extends WizardPage
protected Observable getInterpreterGroupObservable() {
if (fInterpreterGroup instanceof Observable) {
return (Observable) fInterpreterGroup;
- } else {
- return null;
}
+ return null;
}
/**
@@ -1417,7 +1411,7 @@ public abstract class ProjectWizardFirstPage extends WizardPage
* Sets the working sets to which the new project should be added.
*
* @param workingSets
- * the initial selected working sets
+ * the initial selected working sets
* @since 2.0
*/
public void setWorkingSets(IWorkingSet[] workingSets) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/WorkingSetDetector.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/WorkingSetDetector.java
index 9ee96a469..240f3a4ac 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/WorkingSetDetector.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/wizards/WorkingSetDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 xored software, Inc. and others.
+ * Copyright (c) 2009, 2018 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -70,18 +70,17 @@ public class WorkingSetDetector {
return EMPTY_WORKING_SET_ARRAY;
return new IWorkingSet[] { filterWorkingSet };
- } else {
- // If we have been gone into a working set return the working set
- Object input = explorerPart.getViewPartInput();
- if (!(input instanceof IWorkingSet))
- return EMPTY_WORKING_SET_ARRAY;
+ }
+ // If we have been gone into a working set return the working set
+ Object input = explorerPart.getViewPartInput();
+ if (!(input instanceof IWorkingSet))
+ return EMPTY_WORKING_SET_ARRAY;
- IWorkingSet workingSet = (IWorkingSet) input;
- if (!isValidWorkingSet(workingSet))
- return EMPTY_WORKING_SET_ARRAY;
+ IWorkingSet workingSet = (IWorkingSet) input;
+ if (!isValidWorkingSet(workingSet))
+ return EMPTY_WORKING_SET_ARRAY;
- return new IWorkingSet[] { workingSet };
- }
+ return new IWorkingSet[] { workingSet };
}
private IWorkbenchPart getActivePart(IWorkbench workbench) {
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/DelegateUIHelper.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/DelegateUIHelper.java
index 0f1868e12..5181559e9 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/DelegateUIHelper.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/DelegateUIHelper.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
@@ -108,10 +108,10 @@ public class DelegateUIHelper {
private static boolean getBooleanSetting(String key, boolean defaultValue) {
String update = DLTKUIPlugin.getDefault().getDialogSettings().get(key);
- if (update != null)
+ if (update != null) {
return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
+ }
+ return defaultValue;
}
private static void saveBooleanSetting(String key, Button button) {
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DeleteWizard.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DeleteWizard.java
index f63f04f72..71a7b5d8a 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DeleteWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DeleteWizard.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
@@ -36,13 +36,14 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-
public class DeleteWizard extends RefactoringWizard {
public DeleteWizard(Refactoring refactoring) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE | YES_NO_BUTTON_STYLE | NO_PREVIEW_PAGE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
+ super(refactoring, DIALOG_BASED_USER_INTERFACE | YES_NO_BUTTON_STYLE
+ | NO_PREVIEW_PAGE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
setDefaultPageTitle(RefactoringMessages.DeleteWizard_1);
- ((ScriptDeleteProcessor)((DeleteRefactoring)getRefactoring()).getProcessor()).setQueries(new ReorgQueries(this));
+ ((ScriptDeleteProcessor) ((DeleteRefactoring) getRefactoring())
+ .getProcessor()).setQueries(new ReorgQueries(this));
}
@Override
@@ -57,17 +58,17 @@ public class DeleteWizard extends RefactoringWizard {
@Override
public boolean needsProgressMonitor() {
- DeleteRefactoring refactoring= (DeleteRefactoring)getRefactoring();
- RefactoringProcessor processor= refactoring.getProcessor();
+ DeleteRefactoring refactoring = (DeleteRefactoring) getRefactoring();
+ RefactoringProcessor processor = refactoring.getProcessor();
if (processor instanceof ScriptDeleteProcessor) {
- return ((ScriptDeleteProcessor)processor).needsProgressMonitor();
+ return ((ScriptDeleteProcessor) processor).needsProgressMonitor();
}
return super.needsProgressMonitor();
}
private static class DeleteInputPage extends MessageWizardPage {
- private static final String PAGE_NAME= "DeleteInputPage"; //$NON-NLS-1$
- private static final String DIALOG_SETTINGS_DELETE_SUB_PACKAGES= "deleteSubPackages"; //$NON-NLS-1$
+ private static final String PAGE_NAME = "DeleteInputPage"; //$NON-NLS-1$
+ private static final String DIALOG_SETTINGS_DELETE_SUB_PACKAGES = "deleteSubPackages"; //$NON-NLS-1$
private Button fDeleteSubPackagesCheckBox;
public DeleteInputPage() {
@@ -78,13 +79,13 @@ public class DeleteWizard extends RefactoringWizard {
protected String getMessageString() {
try {
if (1 == numberOfSelectedElements()) {
- String pattern= createConfirmationStringForOneElement();
- String name= getNameOfSingleSelectedElement();
- return Messages.format(pattern, new String[] { name });
- } else {
- String pattern= createConfirmationStringForManyElements();
- return Messages.format(pattern, new String[] { String.valueOf(numberOfSelectedElements())});
+ String pattern = createConfirmationStringForOneElement();
+ String name = getNameOfSingleSelectedElement();
+ return Messages.format(pattern, name);
}
+ String pattern = createConfirmationStringForManyElements();
+ return Messages.format(pattern,
+ String.valueOf(numberOfSelectedElements()));
} catch (ModelException e) {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
if (ScriptModelUtil.isExceptionToBeLogged(e))
@@ -113,75 +114,89 @@ public class DeleteWizard extends RefactoringWizard {
*/
private void addDeleteSubPackagesCheckBox() {
- Composite c= new Composite((Composite) getControl(), SWT.NONE);
- GridLayout gd= new GridLayout();
- gd.horizontalSpacing= 10;
+ Composite c = new Composite((Composite) getControl(), SWT.NONE);
+ GridLayout gd = new GridLayout();
+ gd.horizontalSpacing = 10;
c.setLayout(gd);
- GridData data= new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan= 2;
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
c.setLayoutData(data);
- final boolean selection= getRefactoringSettings().getBoolean(DIALOG_SETTINGS_DELETE_SUB_PACKAGES);
+ final boolean selection = getRefactoringSettings()
+ .getBoolean(DIALOG_SETTINGS_DELETE_SUB_PACKAGES);
- fDeleteSubPackagesCheckBox= new Button(c, SWT.CHECK);
- fDeleteSubPackagesCheckBox.setText(RefactoringMessages.DeleteWizard_also_delete_sub_packages);
+ fDeleteSubPackagesCheckBox = new Button(c, SWT.CHECK);
+ fDeleteSubPackagesCheckBox.setText(
+ RefactoringMessages.DeleteWizard_also_delete_sub_packages);
fDeleteSubPackagesCheckBox.setSelection(selection);
- fDeleteSubPackagesCheckBox.addSelectionListener(new SelectionAdapter() {
+ fDeleteSubPackagesCheckBox
+ .addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection());
- }
- });
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ getDeleteProcessor().setDeleteSubPackages(
+ fDeleteSubPackagesCheckBox.getSelection());
+ }
+ });
- getDeleteProcessor().setDeleteSubPackages(fDeleteSubPackagesCheckBox.getSelection());
+ getDeleteProcessor().setDeleteSubPackages(
+ fDeleteSubPackagesCheckBox.getSelection());
}
private String getNameOfSingleSelectedElement() throws ModelException {
- if (getSingleSelectedResource() != null)
+ if (getSingleSelectedResource() != null) {
return ReorgUtils.getName(getSingleSelectedResource());
- else
- return ReorgUtils.getName(getSingleSelectedScriptElement());
+ }
+ return ReorgUtils.getName(getSingleSelectedScriptElement());
}
private IModelElement getSingleSelectedScriptElement() {
- IModelElement[] elements= getSelectedScriptElements();
+ IModelElement[] elements = getSelectedScriptElements();
return elements.length == 1 ? elements[0] : null;
}
private IResource getSingleSelectedResource() {
- IResource[] resources= getSelectedResources();
+ IResource[] resources = getSelectedResources();
return resources.length == 1 ? resources[0] : null;
}
private int numberOfSelectedElements() {
- return getSelectedScriptElements().length + getSelectedResources().length;
+ return getSelectedScriptElements().length
+ + getSelectedResources().length;
}
@Override
protected boolean performFinish() {
- return super.performFinish() || getDeleteProcessor().wasCanceled(); //close the dialog if canceled
+ return super.performFinish() || getDeleteProcessor().wasCanceled(); // close
+ // the
+ // dialog
+ // if
+ // canceled
}
protected boolean saveSettings() {
if (getContainer() instanceof Dialog)
- return ((Dialog) getContainer()).getReturnCode() == IDialogConstants.OK_ID;
+ return ((Dialog) getContainer())
+ .getReturnCode() == IDialogConstants.OK_ID;
return true;
}
@Override
public void dispose() {
if (fDeleteSubPackagesCheckBox != null && saveSettings())
- getRefactoringSettings().put(DIALOG_SETTINGS_DELETE_SUB_PACKAGES, fDeleteSubPackagesCheckBox.getSelection());
+ getRefactoringSettings().put(
+ DIALOG_SETTINGS_DELETE_SUB_PACKAGES,
+ fDeleteSubPackagesCheckBox.getSelection());
super.dispose();
}
- private String createConfirmationStringForOneElement() throws ModelException {
- IModelElement[] elements= getSelectedScriptElements();
+ private String createConfirmationStringForOneElement()
+ throws ModelException {
+ IModelElement[] elements = getSelectedScriptElements();
if (elements.length == 1) {
- IModelElement element= elements[0];
+ IModelElement element = elements[0];
if (isDefaultPackageWithLinkedFiles(element))
return RefactoringMessages.DeleteWizard_3;
@@ -189,69 +204,77 @@ public class DeleteWizard extends RefactoringWizard {
return RefactoringMessages.DeleteWizard_4;
if (isLinkedPackageOrProjectFragment(element))
- //XXX workaround for jcore bugs 31998 and 31456 - linked packages or source folders cannot be deleted properly
+ // XXX workaround for jcore bugs 31998 and 31456 - linked
+ // packages or source folders cannot be deleted properly
return RefactoringMessages.DeleteWizard_6;
return RefactoringMessages.DeleteWizard_5;
- } else {
- if (isLinked(getSelectedResources()[0])) //checked before that this will work
- return RefactoringMessages.DeleteWizard_7;
- else
- return RefactoringMessages.DeleteWizard_8;
}
+ if (isLinked(getSelectedResources()[0])) {// checked before that
+ // this will work
+ return RefactoringMessages.DeleteWizard_7;
+ }
+ return RefactoringMessages.DeleteWizard_8;
}
- private String createConfirmationStringForManyElements() throws ModelException {
- IResource[] resources= getSelectedResources();
- IModelElement[] modelElements= getSelectedScriptElements();
+ private String createConfirmationStringForManyElements()
+ throws ModelException {
+ IResource[] resources = getSelectedResources();
+ IModelElement[] modelElements = getSelectedScriptElements();
if (!containsLinkedResources(resources, modelElements))
return RefactoringMessages.DeleteWizard_9;
if (!containsLinkedPackagesOrProjectFragments(modelElements))
return RefactoringMessages.DeleteWizard_10;
- //XXX workaround for jcore bugs - linked packages or source folders cannot be deleted properly
+ // XXX workaround for jcore bugs - linked packages or source folders
+ // cannot be deleted properly
return RefactoringMessages.DeleteWizard_11;
}
- private static boolean isLinkedPackageOrProjectFragment(IModelElement element) {
- if ((element instanceof IScriptFolder) || (element instanceof IProjectFragment))
+ private static boolean isLinkedPackageOrProjectFragment(
+ IModelElement element) {
+ if ((element instanceof IScriptFolder)
+ || (element instanceof IProjectFragment)) {
return isLinkedResource(element);
- else
- return false;
+ }
+ return false;
}
- private static boolean containsLinkedPackagesOrProjectFragments(IModelElement[] modelElements) {
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
+ private static boolean containsLinkedPackagesOrProjectFragments(
+ IModelElement[] modelElements) {
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
if (isLinkedPackageOrProjectFragment(element))
return true;
}
return false;
}
- private static boolean containsLinkedResources(IResource[] resources, IModelElement[] modelElements) throws ModelException {
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
+ private static boolean containsLinkedResources(IResource[] resources,
+ IModelElement[] modelElements) throws ModelException {
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
if (isLinkedResource(element))
return true;
if (isDefaultPackageWithLinkedFiles(element))
return true;
}
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
if (isLinked(resource))
return true;
}
return false;
}
- private static boolean isDefaultPackageWithLinkedFiles(Object firstElement) throws ModelException {
+ private static boolean isDefaultPackageWithLinkedFiles(
+ Object firstElement) throws ModelException {
if (!ModelElementUtil.isDefaultPackage(firstElement))
return false;
- IScriptFolder defaultPackage= (IScriptFolder)firstElement;
- ISourceModule[] cus= defaultPackage.getSourceModules();
- for (int i= 0; i < cus.length; i++) {
+ IScriptFolder defaultPackage = (IScriptFolder) firstElement;
+ ISourceModule[] cus = defaultPackage.getSourceModules();
+ for (int i = 0; i < cus.length; i++) {
if (isLinkedResource(cus[i]))
return true;
}
@@ -275,7 +298,8 @@ public class DeleteWizard extends RefactoringWizard {
}
private ScriptDeleteProcessor getDeleteProcessor() {
- return (ScriptDeleteProcessor) ((DeleteRefactoring) getRefactoring()).getProcessor();
+ return (ScriptDeleteProcessor) ((DeleteRefactoring) getRefactoring())
+ .getProcessor();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DestinationContentProvider.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DestinationContentProvider.java
index 7f611bf03..8ba8ee782 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DestinationContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/DestinationContentProvider.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
@@ -20,30 +20,30 @@ import org.eclipse.dltk.internal.corext.refactoring.reorg.IReorgDestinationValid
import org.eclipse.dltk.internal.ui.StandardModelElementContentProvider;
import org.eclipse.dltk.ui.DLTKUIPlugin;
-
-
-public final class DestinationContentProvider extends StandardModelElementContentProvider {
+public final class DestinationContentProvider
+ extends StandardModelElementContentProvider {
private IReorgDestinationValidator fValidator;
public DestinationContentProvider(IReorgDestinationValidator validator) {
super(true);
- fValidator= validator;
+ fValidator = validator;
}
@Override
public boolean hasChildren(Object element) {
- if (element instanceof IModelElement){
- IModelElement modelElement= (IModelElement) element;
- if (! fValidator.canChildrenBeDestinations(modelElement))
+ if (element instanceof IModelElement) {
+ IModelElement modelElement = (IModelElement) element;
+ if (!fValidator.canChildrenBeDestinations(modelElement))
return false;
- if (modelElement.getElementType() == IModelElement.PROJECT_FRAGMENT){
- if (((IProjectFragment)modelElement).isArchive())
+ if (modelElement
+ .getElementType() == IModelElement.PROJECT_FRAGMENT) {
+ if (((IProjectFragment) modelElement).isArchive())
return false;
}
} else if (element instanceof IResource) {
- IResource resource= (IResource) element;
- if (! fValidator.canChildrenBeDestinations(resource))
+ IResource resource = (IResource) element;
+ if (!fValidator.canChildrenBeDestinations(resource))
return false;
}
return super.hasChildren(element);
@@ -53,33 +53,38 @@ public final class DestinationContentProvider extends StandardModelElementConten
public Object[] getChildren(Object parentElement) {
try {
if (parentElement instanceof IScriptModel) {
- return concatenate(getScriptProjects((IScriptModel)parentElement), getOpenNonScriptProjects((IScriptModel)parentElement));
- } else {
- Object[] children= super.getChildren(parentElement);
- ArrayList result= new ArrayList(children.length);
- for (int i= 0; i < children.length; i++) {
- if (children[i] instanceof IModelElement) {
- IModelElement modelElement= (IModelElement) children[i];
- if (fValidator.canElementBeDestination(modelElement) || fValidator.canChildrenBeDestinations(modelElement))
- result.add(modelElement);
- } else if (children[i] instanceof IResource) {
- IResource resource= (IResource) children[i];
- if (fValidator.canElementBeDestination(resource) || fValidator.canChildrenBeDestinations(resource))
- result.add(resource);
- }
+ return concatenate(
+ getScriptProjects((IScriptModel) parentElement),
+ getOpenNonScriptProjects((IScriptModel) parentElement));
+ }
+ Object[] children = super.getChildren(parentElement);
+ ArrayList result = new ArrayList(children.length);
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof IModelElement) {
+ IModelElement modelElement = (IModelElement) children[i];
+ if (fValidator.canElementBeDestination(modelElement)
+ || fValidator
+ .canChildrenBeDestinations(modelElement))
+ result.add(modelElement);
+ } else if (children[i] instanceof IResource) {
+ IResource resource = (IResource) children[i];
+ if (fValidator.canElementBeDestination(resource)
+ || fValidator.canChildrenBeDestinations(resource))
+ result.add(resource);
}
- return result.toArray();
}
+ return result.toArray();
} catch (ModelException e) {
DLTKUIPlugin.log(e);
return new Object[0];
}
}
- private static Object[] getOpenNonScriptProjects(IScriptModel model) throws ModelException {
- Object[] nonScriptProjects= model.getForeignResources();
- ArrayList result= new ArrayList(nonScriptProjects.length);
- for (int i= 0; i < nonScriptProjects.length; i++) {
+ private static Object[] getOpenNonScriptProjects(IScriptModel model)
+ throws ModelException {
+ Object[] nonScriptProjects = model.getForeignResources();
+ ArrayList result = new ArrayList(nonScriptProjects.length);
+ for (int i = 0; i < nonScriptProjects.length; i++) {
IProject project = (IProject) nonScriptProjects[i];
if (project.isOpen())
result.add(project);
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/PasteAction.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/PasteAction.java
index bf4c1623e..98fb046d5 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/PasteAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/PasteAction.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
@@ -387,12 +387,12 @@ public class PasteAction extends SelectionDispatchAction {
private Object getTarget(IModelElement[] modelElements,
IResource[] resources) {
if (modelElements.length + resources.length == 1) {
- if (modelElements.length == 1)
+ if (modelElements.length == 1) {
return modelElements[0];
- else
- return resources[0];
- } else
- return getCommonParent(modelElements, resources);
+ }
+ return resources[0];
+ }
+ return getCommonParent(modelElements, resources);
}
@Override
@@ -428,10 +428,9 @@ public class PasteAction extends SelectionDispatchAction {
if (isContainer) {
return true;
- } else {
- IModelElement element = (IModelElement) target;
- return !element.isReadOnly();
}
+ IModelElement element = (IModelElement) target;
+ return !element.isReadOnly();
}
private IContainer getAsContainer(Object target) throws ModelException {
@@ -499,12 +498,12 @@ public class PasteAction extends SelectionDispatchAction {
private Object getTarget(IModelElement[] modelElements,
IResource[] resources) {
if (modelElements.length + resources.length == 1) {
- if (modelElements.length == 1)
+ if (modelElements.length == 1) {
return modelElements[0];
- else
- return resources[0];
- } else
- return getCommonParent(modelElements, resources);
+ }
+ return resources[0];
+ }
+ return getCommonParent(modelElements, resources);
}
private Object getCommonParent(IModelElement[] modelElements,
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameInputWizardPage.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameInputWizardPage.java
index 92893fb25..4cbeaec07 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameInputWizardPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameInputWizardPage.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
@@ -47,12 +47,13 @@ abstract class RenameInputWizardPage extends TextInputWizardPage {
/**
* Creates a new text input page.
- *
+ *
* @param isLastUserPage
- * <code>true</code> if this page is the wizard's last user input
- * page. Otherwise <code>false</code>.
+ * <code>true</code> if this page is the wizard's
+ * last user input page. Otherwise
+ * <code>false</code>.
* @param initialValue
- * the initial value
+ * the initial value
*/
public RenameInputWizardPage(String description, String contextHelpId,
boolean isLastUserPage, String initialValue) {
@@ -113,9 +114,9 @@ abstract class RenameInputWizardPage extends TextInputWizardPage {
* does nothing
*
* @param composite
- * the parent composite
+ * the parent composite
* @param layouter
- * the row layouter to use
+ * the row layouter to use
*/
protected void addAdditionalOptions(Composite composite,
RowLayouter layouter) {
@@ -333,10 +334,10 @@ abstract class RenameInputWizardPage extends TextInputWizardPage {
protected boolean getBooleanSetting(String key, boolean defaultValue) {
String update = getRefactoringSettings().get(key);
- if (update != null)
+ if (update != null) {
return Boolean.valueOf(update).booleanValue();
- else
- return defaultValue;
+ }
+ return defaultValue;
}
protected void saveBooleanSetting(String key, Button checkBox) {
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameSourceModuleWizard.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameSourceModuleWizard.java
index 5237b346c..fa82dd477 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameSourceModuleWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/RenameSourceModuleWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -62,9 +62,8 @@ public class RenameSourceModuleWizard extends RenameRefactoringWizard {
// If renaming a CU we have to remove the file extension
return RenameSourceModuleProcessor
.removeFileNameExtension(result);
- } else {
- return result;
}
+ return result;
}
};
}
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgMoveWizard.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgMoveWizard.java
index 7f163ce42..14c5c21bb 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgMoveWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgMoveWizard.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
@@ -275,9 +275,8 @@ public class ReorgMoveWizard extends RefactoringWizard {
return firstLine;
- } else {
- return super.addLabel(parent);
}
+ return super.addLabel(parent);
}
private boolean canUpdateReferences() {
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgQueries.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgQueries.java
index cc82e101a..bd5643f00 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgQueries.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/ReorgQueries.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
@@ -22,40 +22,42 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
-
public class ReorgQueries implements IReorgQueries {
private final Wizard fWizard;
private final Shell fShell;
- public ReorgQueries(Wizard wizard){
+ public ReorgQueries(Wizard wizard) {
Assert.isNotNull(wizard);
- fWizard= wizard;
- fShell= null;
+ fWizard = wizard;
+ fShell = null;
}
- public ReorgQueries(Shell shell){
+ public ReorgQueries(Shell shell) {
Assert.isNotNull(shell);
- fWizard= null;
- fShell= shell;
+ fWizard = null;
+ fShell = shell;
}
private Shell getShell() {
Assert.isTrue(fShell == null || fWizard == null);
Assert.isTrue(fShell != null || fWizard != null);
- if (fWizard != null)
+ if (fWizard != null) {
return fWizard.getContainer().getShell();
- else
- return fShell;
+ }
+ return fShell;
}
@Override
- public IConfirmQuery createYesYesToAllNoNoToAllQuery(String dialogTitle, boolean allowCancel, int queryID) {
- return new YesYesToAllNoNoToAllQuery(getShell(), allowCancel, dialogTitle);
+ public IConfirmQuery createYesYesToAllNoNoToAllQuery(String dialogTitle,
+ boolean allowCancel, int queryID) {
+ return new YesYesToAllNoNoToAllQuery(getShell(), allowCancel,
+ dialogTitle);
}
@Override
- public IConfirmQuery createYesNoQuery(String dialogTitle, boolean allowCancel, int queryID) {
+ public IConfirmQuery createYesNoQuery(String dialogTitle,
+ boolean allowCancel, int queryID) {
return new YesNoQuery(getShell(), allowCancel, dialogTitle);
}
@@ -64,104 +66,105 @@ public class ReorgQueries implements IReorgQueries {
return new SkipQuery(getShell(), dialogTitle);
}
- private static class YesYesToAllNoNoToAllQuery implements IConfirmQuery{
+ private static class YesYesToAllNoNoToAllQuery implements IConfirmQuery {
private final boolean fAllowCancel;
- private boolean fYesToAll= false;
- private boolean fNoToAll= false;
+ private boolean fYesToAll = false;
+ private boolean fNoToAll = false;
private final Shell fShell;
private final String fDialogTitle;
- YesYesToAllNoNoToAllQuery(Shell parent, boolean allowCancel, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fAllowCancel= allowCancel;
+ YesYesToAllNoNoToAllQuery(Shell parent, boolean allowCancel,
+ String dialogTitle) {
+ fShell = parent;
+ fDialogTitle = dialogTitle;
+ fAllowCancel = allowCancel;
}
@Override
- public boolean confirm(final String question) throws OperationCanceledException {
+ public boolean confirm(final String question)
+ throws OperationCanceledException {
if (fYesToAll)
return true;
if (fNoToAll)
return false;
- final int[] result= new int[1];
+ final int[] result = new int[1];
fShell.getDisplay().syncExec(createQueryRunnable(question, result));
return getResult(result);
}
@Override
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
+ public boolean confirm(String question, Object[] elements)
+ throws OperationCanceledException {
if (fYesToAll)
return true;
if (fNoToAll)
return false;
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, elements, result));
+ final int[] result = new int[1];
+ fShell.getDisplay()
+ .syncExec(createQueryRunnable(question, elements, result));
return getResult(result);
}
- private Runnable createQueryRunnable(final String question, final int[] result) {
+ private Runnable createQueryRunnable(final String question,
+ final int[] result) {
return new Runnable() {
@Override
public void run() {
- int[] resultId= getResultIDs();
-
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
+ int[] resultId = getResultIDs();
+
+ MessageDialog dialog = new MessageDialog(fShell,
+ fDialogTitle, null, question,
+ MessageDialog.QUESTION, getButtonLabels(), 0);
dialog.open();
- if (dialog.getReturnCode() == -1) { //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= fAllowCancel ? IDialogConstants.CANCEL_ID : IDialogConstants.NO_ID;
+ if (dialog.getReturnCode() == -1) { // MessageDialog closed
+ // without choice =>
+ // cancel | no
+ // see also
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
+ result[0] = fAllowCancel ? IDialogConstants.CANCEL_ID
+ : IDialogConstants.NO_ID;
} else {
- result[0]= resultId[dialog.getReturnCode()];
+ result[0] = resultId[dialog.getReturnCode()];
}
}
private String[] getButtonLabels() {
- if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
- return new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.NO_TO_ALL_LABEL,
- IDialogConstants.CANCEL_LABEL };
- else
- return new String[] {
- IDialogConstants.YES_LABEL,
+ if (YesYesToAllNoNoToAllQuery.this.fAllowCancel) {
+ return new String[] { IDialogConstants.YES_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.NO_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL };
+ }
+ return new String[] { IDialogConstants.YES_LABEL,
IDialogConstants.YES_TO_ALL_LABEL,
IDialogConstants.NO_LABEL,
- IDialogConstants.NO_TO_ALL_LABEL};
+ IDialogConstants.NO_TO_ALL_LABEL };
}
private int[] getResultIDs() {
- if (YesYesToAllNoNoToAllQuery.this.fAllowCancel)
- return new int[] {
- IDialogConstants.YES_ID,
- IDialogConstants.YES_TO_ALL_ID,
- IDialogConstants.NO_ID,
- IDialogConstants.NO_TO_ALL_ID,
- IDialogConstants.CANCEL_ID};
- else
- return new int[] {
- IDialogConstants.YES_ID,
+ if (YesYesToAllNoNoToAllQuery.this.fAllowCancel) {
+ return new int[] { IDialogConstants.YES_ID,
+ IDialogConstants.YES_TO_ALL_ID,
+ IDialogConstants.NO_ID,
+ IDialogConstants.NO_TO_ALL_ID,
+ IDialogConstants.CANCEL_ID };
+ }
+ return new int[] { IDialogConstants.YES_ID,
IDialogConstants.YES_TO_ALL_ID,
IDialogConstants.NO_ID,
- IDialogConstants.NO_TO_ALL_ID};
+ IDialogConstants.NO_TO_ALL_ID };
}
};
}
- private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) {
+ private Runnable createQueryRunnable(final String question,
+ final Object[] elements, final int[] result) {
return () -> {
ListDialog dialog = new YesNoListDialog(fShell, true);
dialog.setAddCancelButton(false);
@@ -177,100 +180,107 @@ public class ReorgQueries implements IReorgQueries {
};
}
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- case IDialogConstants.YES_TO_ALL_ID:
- fYesToAll= true;
- return true;
- case IDialogConstants.YES_ID:
- return true;
- case IDialogConstants.CANCEL_ID:
- throw new OperationCanceledException();
- case IDialogConstants.NO_ID:
- return false;
- case IDialogConstants.NO_TO_ALL_ID:
- fNoToAll= true;
- return false;
- default:
- Assert.isTrue(false);
- return false;
+ private boolean getResult(int[] result)
+ throws OperationCanceledException {
+ switch (result[0]) {
+ case IDialogConstants.YES_TO_ALL_ID:
+ fYesToAll = true;
+ return true;
+ case IDialogConstants.YES_ID:
+ return true;
+ case IDialogConstants.CANCEL_ID:
+ throw new OperationCanceledException();
+ case IDialogConstants.NO_ID:
+ return false;
+ case IDialogConstants.NO_TO_ALL_ID:
+ fNoToAll = true;
+ return false;
+ default:
+ Assert.isTrue(false);
+ return false;
}
}
}
- private static class YesNoQuery implements IConfirmQuery{
+ private static class YesNoQuery implements IConfirmQuery {
private final Shell fShell;
private final String fDialogTitle;
private final boolean fAllowCancel;
- YesNoQuery(Shell parent, boolean allowCancel, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fAllowCancel= allowCancel;
+ YesNoQuery(Shell parent, boolean allowCancel, String dialogTitle) {
+ fShell = parent;
+ fDialogTitle = dialogTitle;
+ fAllowCancel = allowCancel;
}
@Override
- public boolean confirm(String question) throws OperationCanceledException {
- final int[] result= new int[1];
+ public boolean confirm(String question)
+ throws OperationCanceledException {
+ final int[] result = new int[1];
fShell.getDisplay().syncExec(createQueryRunnable(question, result));
return getResult(result);
}
@Override
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
- final int[] result= new int[1];
- fShell.getDisplay().syncExec(createQueryRunnable(question, elements, result));
+ public boolean confirm(String question, Object[] elements)
+ throws OperationCanceledException {
+ final int[] result = new int[1];
+ fShell.getDisplay()
+ .syncExec(createQueryRunnable(question, elements, result));
return getResult(result);
}
- private Runnable createQueryRunnable(final String question, final int[] result){
+ private Runnable createQueryRunnable(final String question,
+ final int[] result) {
return new Runnable() {
@Override
public void run() {
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
+ MessageDialog dialog = new MessageDialog(fShell,
+ fDialogTitle, null, question,
+ MessageDialog.QUESTION, getButtonLabels(), 0);
dialog.open();
switch (dialog.getReturnCode()) {
- case -1 : //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= fAllowCancel ? IDialogConstants.CANCEL_ID : IDialogConstants.NO_ID;
- break;
- case 0 :
- result[0]= IDialogConstants.YES_ID;
- break;
- case 1 :
- result[0]= IDialogConstants.NO_ID;
- break;
- case 2 :
- if (fAllowCancel)
- result[0]= IDialogConstants.CANCEL_ID;
- else
- Assert.isTrue(false);
- break;
- default :
+ case -1: // MessageDialog closed without choice => cancel |
+ // no
+ // see also
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
+ result[0] = fAllowCancel ? IDialogConstants.CANCEL_ID
+ : IDialogConstants.NO_ID;
+ break;
+ case 0:
+ result[0] = IDialogConstants.YES_ID;
+ break;
+ case 1:
+ result[0] = IDialogConstants.NO_ID;
+ break;
+ case 2:
+ if (fAllowCancel)
+ result[0] = IDialogConstants.CANCEL_ID;
+ else
Assert.isTrue(false);
- break;
+ break;
+ default:
+ Assert.isTrue(false);
+ break;
}
}
private String[] getButtonLabels() {
- if (fAllowCancel)
- return new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
- else
- return new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL};
+ if (fAllowCancel) {
+ return new String[] { IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.CANCEL_LABEL };
+ }
+ return new String[] { IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL };
}
};
}
- private Runnable createQueryRunnable(final String question, final Object[] elements, final int[] result) {
+ private Runnable createQueryRunnable(final String question,
+ final Object[] elements, final int[] result) {
return () -> {
ListDialog dialog = new YesNoListDialog(fShell, false);
dialog.setAddCancelButton(false);
@@ -286,100 +296,107 @@ public class ReorgQueries implements IReorgQueries {
};
}
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- case IDialogConstants.YES_ID:
- return true;
- case IDialogConstants.CANCEL_ID:
- throw new OperationCanceledException();
- case IDialogConstants.NO_ID:
- return false;
- default:
- Assert.isTrue(false);
- return false;
+ private boolean getResult(int[] result)
+ throws OperationCanceledException {
+ switch (result[0]) {
+ case IDialogConstants.YES_ID:
+ return true;
+ case IDialogConstants.CANCEL_ID:
+ throw new OperationCanceledException();
+ case IDialogConstants.NO_ID:
+ return false;
+ default:
+ Assert.isTrue(false);
+ return false;
}
}
}
- private static class SkipQuery implements IConfirmQuery{
+ private static class SkipQuery implements IConfirmQuery {
private final Shell fShell;
private final String fDialogTitle;
private boolean fSkipAll;
- SkipQuery(Shell parent, String dialogTitle){
- fShell= parent;
- fDialogTitle= dialogTitle;
- fSkipAll= false;
+ SkipQuery(Shell parent, String dialogTitle) {
+ fShell = parent;
+ fDialogTitle = dialogTitle;
+ fSkipAll = false;
}
@Override
- public boolean confirm(String question) throws OperationCanceledException {
+ public boolean confirm(String question)
+ throws OperationCanceledException {
if (fSkipAll)
return false;
- final int[] result= new int[1];
+ final int[] result = new int[1];
fShell.getDisplay().syncExec(createQueryRunnable(question, result));
return getResult(result);
}
@Override
- public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
- throw new UnsupportedOperationException("Not supported for skip queries"); //$NON-NLS-1$
+ public boolean confirm(String question, Object[] elements)
+ throws OperationCanceledException {
+ throw new UnsupportedOperationException(
+ "Not supported for skip queries"); //$NON-NLS-1$
}
- private Runnable createQueryRunnable(final String question, final int[] result){
+ private Runnable createQueryRunnable(final String question,
+ final int[] result) {
return new Runnable() {
@Override
public void run() {
- MessageDialog dialog= new MessageDialog(
- fShell,
- fDialogTitle,
- null,
- question,
- MessageDialog.QUESTION,
- getButtonLabels(),
- 0);
+ MessageDialog dialog = new MessageDialog(fShell,
+ fDialogTitle, null, question,
+ MessageDialog.QUESTION, getButtonLabels(), 0);
dialog.open();
switch (dialog.getReturnCode()) {
- case -1 : //MessageDialog closed without choice => cancel | no
- //see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
- result[0]= IDialogConstants.CANCEL_ID;
- break;
- default:
- result[0]= dialog.getReturnCode();
+ case -1: // MessageDialog closed without choice => cancel |
+ // no
+ // see also
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=48400
+ result[0] = IDialogConstants.CANCEL_ID;
+ break;
+ default:
+ result[0] = dialog.getReturnCode();
}
}
private String[] getButtonLabels() {
- return new String[] {IDialogConstants.SKIP_LABEL, ReorgMessages.ReorgQueries_skip_all, IDialogConstants.CANCEL_LABEL};
+ return new String[] { IDialogConstants.SKIP_LABEL,
+ ReorgMessages.ReorgQueries_skip_all,
+ IDialogConstants.CANCEL_LABEL };
}
};
}
- private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- // skip button
- case 0:
- return false;
- // skip all button
- case 1:
- fSkipAll= true;
- return false;
- // Cancel button
- case 2:
- throw new OperationCanceledException();
- default:
- return false;
+ private boolean getResult(int[] result)
+ throws OperationCanceledException {
+ switch (result[0]) {
+ // skip button
+ case 0:
+ return false;
+ // skip all button
+ case 1:
+ fSkipAll = true;
+ return false;
+ // Cancel button
+ case 2:
+ throw new OperationCanceledException();
+ default:
+ return false;
}
}
}
private static final class YesNoListDialog extends ListDialog {
private final boolean fYesToAllNoToAll;
+
private YesNoListDialog(Shell parent, boolean includeYesToAllNoToAll) {
- super(parent, SWT.TITLE | SWT.BORDER | SWT.RESIZE | SWT.APPLICATION_MODAL);
- fYesToAllNoToAll= includeYesToAllNoToAll;
+ super(parent, SWT.TITLE | SWT.BORDER | SWT.RESIZE
+ | SWT.APPLICATION_MODAL);
+ fYesToAllNoToAll = includeYesToAllNoToAll;
}
@Override
@@ -391,13 +408,18 @@ public class ReorgQueries implements IReorgQueries {
@Override
protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
+ createButton(parent, IDialogConstants.YES_ID,
+ IDialogConstants.YES_LABEL, true);
if (fYesToAllNoToAll)
- createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false);
- createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
+ createButton(parent, IDialogConstants.YES_TO_ALL_ID,
+ IDialogConstants.YES_TO_ALL_LABEL, false);
+ createButton(parent, IDialogConstants.NO_ID,
+ IDialogConstants.NO_LABEL, false);
if (fYesToAllNoToAll)
- createButton(parent, IDialogConstants.NO_TO_ALL_ID, IDialogConstants.NO_TO_ALL_LABEL, false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ createButton(parent, IDialogConstants.NO_TO_ALL_ID,
+ IDialogConstants.NO_TO_ALL_LABEL, false);
+ createButton(parent, IDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL, false);
}
}
}

Back to the top